- 🇬🇧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.
- Assigned to ressa
- 🇩🇰Denmark ressa Copenhagen
Thanks @ptmkenny, let's get this moving. I have updated the Issue Summary, and added a few extra tasks.
- Merge request !123Add CSS icon example in README under new Customize section → (Open) created by ressa
- 🇯🇵Japan ptmkenny
@ressa How can this be "Needs review" when you turned it into a meta issue? If an issue has multiple tasks, it can't be "needs review" until all the tasks are completed. Further, your MR ignores all the comments that have already been written. It seems like you should've opened a separate issue instead of adding to this one.
- 🇯🇵Japan ptmkenny
ptmkenny → changed the visibility of the branch 3157623-provide-documentation-for to hidden.
- 🇯🇵Japan ptmkenny
@ressa I've reverted your changes to the IS. If you want to create a meta issue, please create a new issue and link to this one.
- 🇩🇰Denmark ressa Copenhagen
I am sorry, I assumed it was all right, since this issue had been stale since 2020 ...
But I guess I just need to re-do everything in a new issue. - 🇯🇵Japan ptmkenny
As far as I know, the code in #2 is ready to go, but there's a bigger question that needs to be answered, which is "Is flag going to provide code examples for 4.x like it did for previous versions?" or will people be referred to the API docs instead.
This is something for the maintainer to decide.
Also, while the examples in #2 are ready to go, it doesn't cover the same scope as the docs for 3.x.