Drupal 8  8.0.2
ActiveLinkResponseFilter Class Reference
Inheritance diagram for ActiveLinkResponseFilter:

Public Member Functions

 __construct (AccountInterface $current_user, CurrentPathStack $current_path, PathMatcherInterface $path_matcher, LanguageManagerInterface $language_manager)
 onResponse (FilterResponseEvent $event)

Static Public Member Functions

static setLinkActiveClass ($html_markup, $current_path, $is_front, $url_language, array $query)
static getSubscribedEvents ()

Protected Attributes


Detailed Description

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.

See Also

Constructor & Destructor Documentation

__construct ( AccountInterface  $current_user,
CurrentPathStack  $current_path,
PathMatcherInterface  $path_matcher,
LanguageManagerInterface  $language_manager 

Constructs a new ActiveLinkResponseFilter instance.

\Drupal\Core\Session\AccountInterface$current_userThe current user.
\Drupal\Core\Path\CurrentPathStack$current_pathThe current path.
\Drupal\Core\Path\PathMatcherInterface$path_matcherThe path matcher.
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.

References Drupal\currentUser(), and Drupal\languageManager().

Here is the call graph for this function:

Member Function Documentation

static getSubscribedEvents ( )


onResponse ( FilterResponseEvent  $event)

Sets the 'is-active' class on links.

\Symfony\Component\HttpKernel\Event\FilterResponseEvent$eventThe response event.

References Drupal\currentUser(), Drupal\languageManager(), and LanguageInterface\TYPE_URL.

Here is the call graph for this function:

static setLinkActiveClass (   $html_markup,
array  $query 

Sets the "is-active" class on relevant links.

This is a PHP implementation of the drupal.active-link JavaScript library.

string$html_markup,.The HTML markup to update.
string$current_pathThe system path of the currently active page.
bool$is_frontWhether the current page is the front page (which implies the current path might also be <front>).
string$url_languageThe language code of the current URL.
array$queryThe query string for the current URL.
string The updated HTML markup.
Once a future version of PHP supports parsing HTML5 properly (i.e. doesn't fail on https://www.drupal.org/comment/7938201#comment-7938201) then we can get rid of this manual parsing and use DOMDocument instead.

References Json\encode().

Referenced by ActiveLinkResponseFilterTest\testSetLinkActiveClass().

Here is the call graph for this function:

Here is the caller graph for this function:

The documentation for this class was generated from the following file: