public function FlaggingStorage::loadIsFlagged in Flag 8.4
Loads a list of flags the entity is flagged with for the given account.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to check.
\Drupal\Core\Session\AccountInterface $account: The user account to check for.
string $session_id: (optional) The session ID. This must be supplied if $account is the anonymous user.
Return value
string[] A list of flag_ids that for which the given entity is flagged, either globally or for the given account.
Throws
\LogicException Thrown when $account is anonymous but no associated session ID is specified.
Overrides FlaggingStorageInterface::loadIsFlagged
File
- src/
Entity/ Storage/ FlaggingStorage.php, line 39
Class
- FlaggingStorage
- Default SQL flagging storage.
Namespace
Drupal\flag\Entity\StorageCode
public function loadIsFlagged(EntityInterface $entity, AccountInterface $account, $session_id = NULL) {
if ($account
->isAnonymous() && is_null($session_id)) {
throw new \LogicException('Anonymous users must be identified by session_id');
}
$flag_ids = $this
->loadIsFlaggedMultiple([
$entity,
], $account, $session_id);
return $flag_ids[$entity
->id()];
}