public ActiveLinkResponseFilter::onResponse(FilterResponseEvent $event)
Sets the 'is-active' class on links.
\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The response event.
public function onResponse(FilterResponseEvent $event) { // Only care about HTML responses. if (stripos($event->getResponse()->headers->get('Content-Type'), 'text/html') === FALSE) { return; } // For authenticated users, the 'is-active' class is set in JavaScript. // @see system_page_attachments() if ($this->currentUser->isAuthenticated()) { return; } $response = $event->getResponse(); $response->setContent(static::setLinkActiveClass( $response->getContent(), ltrim($this->currentPath->getPath(), '/'), $this->pathMatcher->isFrontPage(), $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(), $event->getRequest()->query->all() )); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!EventSubscriber!ActiveLinkResponseFilter.php/function/ActiveLinkResponseFilter::onResponse/8.1.x