public function TermSelection::countReferenceableEntities in Drupal 9
Same name and namespace in other branches
- 8 core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::countReferenceableEntities()
Counts entities that are referenceable.
Parameters
string $match: (optional) Text to match the label against. Defaults to NULL.
string $match_operator: (optional) Operator to be used for string matching. Defaults to "CONTAINS".
Return value
int The number of referenceable entities.
Overrides DefaultSelection::countReferenceableEntities
File
- core/
modules/ taxonomy/ src/ Plugin/ EntityReferenceSelection/ TermSelection.php, line 85
Class
- TermSelection
- Provides specific access control for the taxonomy_term entity type.
Namespace
Drupal\taxonomy\Plugin\EntityReferenceSelectionCode
public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS') {
if ($match) {
return parent::countReferenceableEntities($match, $match_operator);
}
$total = 0;
$referenceable_entities = $this
->getReferenceableEntities($match, $match_operator, 0);
foreach ($referenceable_entities as $bundle => $entities) {
$total += count($entities);
}
return $total;
}