Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USAGOV-1773-clear-menu-link: #1923

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Drupal\usagov_ssg_postprocessing\EventSubscriber;

use Drupal\Core\Cache\CacheCollectorInterface;
use Drupal\tome_static\Event\TomeStaticEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Clears the menu active trail cache between Tome requests.
*
* @internal
*/
class RequestPrepareSubscriber implements EventSubscriberInterface {

public function __construct(
private CacheCollectorInterface $menu_active_trail,
) {

}

public function requestPrepare() {
$this->menu_active_trail->clear();
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[TomeStaticEvents::REQUEST_PREPARE][] = ['requestPrepare'];
return $events;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ services:
class: '\Drupal\usagov_ssg_postprocessing\EventSubscriber\PublishedPagesSubscriber'
tags:
- { name: 'event_subscriber' }
usagov_ssg_postprocessing_request_prepare_events_subscriber:
class: '\Drupal\usagov_ssg_postprocessing\EventSubscriber\RequestPrepareSubscriber'
arguments: ['@menu.active_trail']
tags:
- { name: 'event_subscriber' }