public function EntityTypeInfo::entityOperation in View Modes Display 8.2
Adds preview 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 87
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\view_modes_displayCode
public function entityOperation(EntityInterface $entity) {
$operations = [];
if ($this->currentUser
->hasPermission('preview view modes')) {
if ($entity
->hasLinkTemplate('vmd-preview-list')) {
$operations['view-mode-display'] = [
'title' => $this
->t('Preview'),
'weight' => 100,
'url' => $entity
->toUrl('vmd-preview-list'),
];
}
}
return $operations;
}