ActiveLinkResponseFilter
class ActiveLinkResponseFilter implements EventSubscriberInterface (View source)
Subscribes to filter HTML responses, to set the 'is-active' class on links.
Only for anonymous users; for authenticated users, the active-link asset library is loaded.
Properties
| protected AccountInterface | $currentUser | The current user. |
|
| protected CurrentPathStack | $currentPath | The current path. |
|
| protected PathMatcherInterface | $pathMatcher | The path matcher. |
|
| protected LanguageManagerInterface | $languageManager | The language manager. |
Methods
Constructs a new ActiveLinkResponseFilter instance.
Sets the 'is-active' class on links.
Sets the "is-active" class on relevant links.
{@inheritdoc}
Details
__construct(AccountInterface $current_user, CurrentPathStack $current_path, PathMatcherInterface $path_matcher, LanguageManagerInterface $language_manager)
Constructs a new ActiveLinkResponseFilter instance.
onResponse(ResponseEvent $event)
Sets the 'is-active' class on links.
static string
setLinkActiveClass(string $html_markup, string $current_path, bool $is_front, string $url_language, array $query)
Sets the "is-active" class on relevant links.
This is a PHP implementation of the drupal.active-link JavaScript library.
static
getSubscribedEvents()
{@inheritdoc}