- 🇬🇧United Kingdom problue solutions Northern Ireland
Discovering whether a piece of content is flagged
Use the isFlagged() method to find out if an item is flagged.
Example:
$flag_id = 'bookmark';
$flag_service = \Drupal::service('flag');
$flag = $flag_service->getFlagById($flag_id);if ($flag && $flag->isFlagged($entity) {
print "This entity has been bookmarked!";
}Is this supposed to return true if the flag id is flagged by any user for the given entity?
Im trying this code and it isnt returning true for a flag id that i know for sure is flagged by at least one user for the given entity.