public function EntityTypeInfo::entityOperation in Devel 8
Same name and namespace in other branches
- 8.3 src/EntityTypeInfo.php \Drupal\devel\EntityTypeInfo::entityOperation()
- 8.2 src/EntityTypeInfo.php \Drupal\devel\EntityTypeInfo::entityOperation()
- 4.x src/EntityTypeInfo.php \Drupal\devel\EntityTypeInfo::entityOperation()
Adds devel operations on entity that supports it.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity on which to define an operation.
Return value
array An array of operation definitions.
See also
File
- src/
EntityTypeInfo.php, line 82
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\develCode
public function entityOperation(EntityInterface $entity) {
$operations = [];
if ($this->currentUser
->hasPermission('access devel information')) {
if ($entity
->hasLinkTemplate('devel-load')) {
$operations['devel'] = [
'title' => $this
->t('Devel'),
'weight' => 100,
'url' => $entity
->toUrl('devel-load'),
];
}
elseif ($entity
->hasLinkTemplate('devel-render')) {
$operations['devel'] = [
'title' => $this
->t('Devel'),
'weight' => 100,
'url' => $entity
->toUrl('devel-render'),
];
}
}
return $operations;
}