diff --git a/src/EventSubscriber/UwLayoutBuilderEventSubscriber.php b/src/EventSubscriber/UwLayoutBuilderEventSubscriber.php new file mode 100644 index 0000000000000000000000000000000000000000..81f2c9bc994143d942ae4886592a0256135fa909 --- /dev/null +++ b/src/EventSubscriber/UwLayoutBuilderEventSubscriber.php @@ -0,0 +1,36 @@ +<?php + +namespace Drupal\uw_cfg_common\EventSubscriber; + +use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent; +use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * UW custom block fact and figures event subscriber. + */ +class UwLayoutBuilderEventSubscriber implements EventSubscriberInterface { + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + return [ + HookEventDispatcherInterface::FORM_ALTER => 'alterForm', + ]; + } + + /** + * Alter form. + * + * @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event + * The event. + */ + public function alterForm(FormAlterEvent $event): void { + $form = &$event->getForm(); + if (isset($form['actions']['revert']) && substr($form['#form_id'], -20) == '_layout_builder_form') { + unset($form['actions']['revert']); + } + } + +} diff --git a/uw_cfg_common.services.yml b/uw_cfg_common.services.yml index a2cc6f8f79e58d8f5575e13373529c9ff3c3f39e..d577a012687f929c10b7a0159eb80f13b4240028 100644 --- a/uw_cfg_common.services.yml +++ b/uw_cfg_common.services.yml @@ -16,3 +16,7 @@ services: uw_cfg_common.uw_analytics: class: \Drupal\uw_cfg_common\Service\UWAnalytics arguments: ['@router.admin_context', '@current_route_match'] + uw_cfg_common.event_subscriber: + class: '\Drupal\uw_cfg_common\EventSubscriber\UwLayoutBuilderEventSubscriber' + tags: + - { name: 'event_subscriber' }