public function FlagListsService::getAllFlagForList in Flag Lists 8
Same name and namespace in other branches
- 4.0.x src/FlagListsService.php \Drupal\flag_lists\FlagListsService::getAllFlagForList()
Get all Flag For List, i.e. all Flags tagged as available.
Parameters
string $entity_type: The entity wanted entity type.
string $bundle: The wanted bundle of the entity.
Return value
Drupal\flag_lists\Entity\FlagForList[] An array of found Flag For Lists.
1 call to FlagListsService::getAllFlagForList()
- FlagListsService::getUsersFlagForList in src/
FlagListsService.php - Get a user's Flag For List, i.e. all Flags tagged as available.
File
- src/
FlagListsService.php, line 69
Class
- FlagListsService
- Class FlagForList service.
Namespace
Drupal\flag_listsCode
public function getAllFlagForList($entity_type = NULL, $bundle = NULL) {
$query = $this->entityQueryManager
->get('flag_for_list');
if ($entity_type != NULL) {
$query
->condition('entity_type', $entity_type);
}
$ids = $query
->execute();
$flags = $this
->getFlagForListByIds($ids);
if (isset($bundle)) {
$flags = array_filter($flags, function (FlagForList $flag) use ($bundle) {
$bundles = $flag
->getApplicableBundles();
return in_array($bundle, $bundles);
});
}
return $flags;
}