function EntityListBuilder::getOperations
Provides an array of information to build a list of operation links.
@todo Uncomment new method parameters before drupal:12.0.0.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.
phpcs:disable Drupal.Commenting
\Drupal\Core\Cache\CacheableMetadata|null $cacheability: The cacheable metadata to add to if your operations vary by or depend on something. phpcs:enable
Return value
array An associative array of operation link data for this list, keyed by operation name, containing the following key-value pairs:
- title: The localized title of the operation.
- url: An instance of \Drupal\Core\Url for the operation URL.
- weight: The weight of this operation.
Overrides EntityListBuilderInterface::getOperations
5 calls to EntityListBuilder::getOperations()
- BlockContentListBuilder::getOperations in core/
modules/ block_content/ src/ BlockContentListBuilder.php - ConfigTranslationEntityListBuilder::getOperations in core/
modules/ config_translation/ src/ Controller/ ConfigTranslationEntityListBuilder.php - EntityDisplayModeListBuilder::getOperations in core/
modules/ field_ui/ src/ EntityDisplayModeListBuilder.php - EntityListBuilder::buildOperations in core/
lib/ Drupal/ Core/ Entity/ EntityListBuilder.php - Builds a renderable list of operation links for the entity.
- UserListBuilder::getOperations in core/
modules/ user/ src/ UserListBuilder.php
4 methods override EntityListBuilder::getOperations()
- BlockContentListBuilder::getOperations in core/
modules/ block_content/ src/ BlockContentListBuilder.php - ConfigTranslationEntityListBuilder::getOperations in core/
modules/ config_translation/ src/ Controller/ ConfigTranslationEntityListBuilder.php - EntityDisplayModeListBuilder::getOperations in core/
modules/ field_ui/ src/ EntityDisplayModeListBuilder.php - UserListBuilder::getOperations in core/
modules/ user/ src/ UserListBuilder.php
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityListBuilder.php, line 132
Class
- EntityListBuilder
- Defines a generic implementation to build a listing of entities.
Namespace
Drupal\Core\EntityCode
public function getOperations(EntityInterface $entity) {
$args = func_get_args();
$cacheability = $args[1] ?? new CacheableMetadata();
$operations = $this->getDefaultOperations($entity, $cacheability);
$operations += $this->moduleHandler()
->invokeAll('entity_operation', [
$entity,
$cacheability,
]);
$this->moduleHandler
->alter('entity_operation', $operations, $entity, $cacheability);
uasort($operations, '\\Drupal\\Component\\Utility\\SortArray::sortByWeightElement');
return $operations;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.