public function FlagService::getFlaggableById in Flag 8.4
Loads the flaggable entity given the flag entity and entity ID.
$flag = \Drupal::service('flag')
->getFlagById('bookmark');
$flaggable = \Drupal::service('flag')
->getFlaggableById($flag, $entity_id);
Parameters
\Drupal\flag\FlagInterface $flag: The flag entity.
int $entity_id: The ID of the flaggable entity.
Return value
\Drupal\Core\Entity\EntityInterface|null The flaggable entity object.
Overrides FlagServiceInterface::getFlaggableById
File
- src/
FlagService.php, line 201
Class
- FlagService
- Flag service.
Namespace
Drupal\flagCode
public function getFlaggableById(FlagInterface $flag, $entity_id) {
return $this->entityTypeManager
->getStorage($flag
->getFlaggableEntityTypeId())
->load($entity_id);
}