public function EntityTypeInfo::entityOperation in Form mode manager 8.2
Same name and namespace in other branches
- 8 src/EntityTypeInfo.php \Drupal\form_mode_manager\EntityTypeInfo::entityOperation()
Adds Form Mode Manager 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 109
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\form_mode_managerCode
public function entityOperation(EntityInterface $entity) {
$operations = [];
$form_modes = $this->formModeManager
->getFormModesByEntity($entity
->getEntityTypeId());
foreach ($form_modes as $form_mode_name => $form_mode) {
if ($this
->grantAccessToFormModeOperation($form_mode, $entity)) {
$operations += [
$form_mode_name => [
'title' => $this
->t('Edit as @form_mode_name', [
'@form_mode_name' => $form_mode['label'],
])
->render(),
'url' => $entity
->toUrl("edit-form.{$form_mode_name}"),
'weight' => 31,
],
];
}
}
return $operations;
}