I'm trying to access the comment field value in controller. With the following code I'm able to access the particular comment object.
$comment = \Drupal::entityManager()->getStorage('comment')->load($commentID);
When I try print_r for the $comment variable, I can see the fully loaded comment object.
I understand I cannot access the values by traversing the object since the values are protected. I tried $comment->get('subject')->value
function, this time its looping and doesn't return any results.
How do I achieve retrieving the value of specific fields associated with comment entity?
$comment->get('subject')->value
seems OK, this should work.