Skip to content
Snippets Groups Projects
Commit 1cb6eee3 authored by Neslee Canil Pinto's avatar Neslee Canil Pinto
Browse files

Functionality for displaying layout option in content listing page

parent e6dbd327
No related branches found
No related tags found
No related merge requests found
......@@ -15,8 +15,10 @@ Allows user to customize Layout Builder Options.
1. If Disable option is checked in module configuration form, This module
disables option "Allow each Entity Type to have its layout customized"
in Manage Display Page for Respective Entity Type.
2. Module gives user quick links(Configure, Move and Remove Block) on hover
2. Gives user quick links(Configure, Move and Remove Block) on hover
of its particular block, which will save users time.
3. Adds a 'Layout' operation link to Layout Builder content on content listing
pages.
REQUIREMENTS
......
name: 'Layout Builder Customizer'
description: 'Allows user to customize Layout Builder.'
core_version_requirement: ^8.8 || ^9
type: module
package: Layout Builder
core_version_requirement: ^8.8 || ^9
configure: layout_builder_customizer.settings_form
dependencies:
- drupal:layout_builder
......@@ -5,7 +5,9 @@
* Layout Builder Customizer module file.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Implements hook_form_alter().
......@@ -31,6 +33,29 @@ function layout_builder_customizer_form_alter(&$form, FormStateInterface $formSt
}
}
/**
* Implements hook_entity_operation().
*/
function layout_builder_customizer_entity_operation(EntityInterface $entity) {
$account = \Drupal::currentUser();
$entity_type_id = $entity->getEntityTypeId();
$route_name = "layout_builder.overrides.$entity_type_id.view";
$route_parameters = [
$entity_type_id => $entity->id(),
];
$access_manager = \Drupal::service('access_manager');
if (!$access_manager->checkNamedRoute($route_name, $route_parameters, $account)) {
return;
}
return [
'Layout' => [
'title' => t('Layout'),
'weight' => 50,
'url' => Url::fromRoute($route_name, $route_parameters),
],
];
}
/**
* Implements hook_page_attachments_alter().
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment