function helper_entity_operation in Helper 8
Implements hook_entity_operation().
File
- ./
helper.module, line 16 - Main file for the Helper module.
Code
function helper_entity_operation(EntityInterface $entity) {
$operations = [];
if ($entity instanceof FieldableEntityInterface && \Drupal::moduleHandler()
->moduleExists('layout_builder')) {
$entity_type_id = $entity
->getEntityTypeId();
$url = Url::fromRoute('layout_builder.overrides.' . $entity_type_id . '.view', [
$entity_type_id => $entity
->id(),
]);
if ($url
->access()) {
$operations['layout'] = [
'title' => t('Layout'),
'weight' => 50,
'url' => $url,
];
}
}
return $operations;
}