public function FlagService::unflagAllByEntity in Flag 8.4
Remove all flaggings from an entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
Overrides FlagServiceInterface::unflagAllByEntity
1 call to FlagService::unflagAllByEntity()
- FlagService::userFlagRemoval in src/
FlagService.php - Shared helper for user account cancellation or deletion.
File
- src/
FlagService.php, line 317
Class
- FlagService
- Flag service.
Namespace
Drupal\flagCode
public function unflagAllByEntity(EntityInterface $entity) {
$query = $this->entityTypeManager
->getStorage('flagging')
->getQuery();
$query
->condition('entity_type', $entity
->getEntityTypeId())
->condition('entity_id', $entity
->id());
$ids = $query
->execute();
$flaggings = $this
->getFlaggingsByIds($ids);
$this->entityTypeManager
->getStorage('flagging')
->delete($flaggings);
}