Drupal 8  8.0.2
AjaxBasePageNegotiator Class Reference
Inheritance diagram for AjaxBasePageNegotiator:

Public Member Functions

 __construct (CsrfTokenGenerator $token_generator, ConfigFactoryInterface $config_factory, RequestStack $request_stack)
 
 applies (RouteMatchInterface $route_match)
 
 determineActiveTheme (RouteMatchInterface $route_match)
 

Protected Attributes

 $csrfGenerator
 
 $configFactory
 
 $requestStack
 

Detailed Description

Defines a theme negotiator that deals with the active theme on ajax requests.

Many different pages can invoke an Ajax request to a generic Ajax path. It is almost always desired for an Ajax response to be rendered using the same theme as the base page, because most themes are built with the assumption that they control the entire page, so if the CSS for two themes are both loaded for a given page, they may conflict with each other. For example, Bartik is Drupal's default theme, and Seven is Drupal's default administration theme. Depending on whether the "Use the administration theme when editing or creating content" checkbox is checked, the node edit form may be displayed in either theme, but the Ajax response to the Field module's "Add another item" button should be rendered using the same theme as the rest of the page.

Therefore specify '_theme: ajax_base_page' as part of the router options.

Constructor & Destructor Documentation

__construct ( CsrfTokenGenerator  $token_generator,
ConfigFactoryInterface  $config_factory,
RequestStack  $request_stack 
)

Constructs a new AjaxBasePageNegotiator.

Parameters
\Drupal\Core\Access\CsrfTokenGenerator$token_generatorThe CSRF token generator.
\Drupal\Core\Config\ConfigFactoryInterface$config_factoryThe config factory.
\Symfony\Component\HttpFoundation\RequestStack$request_stackThe request stack used to retrieve the current request.

References Drupal\configFactory(), and Drupal\requestStack().

Here is the call graph for this function:

Member Function Documentation

applies ( RouteMatchInterface  $route_match)

{Whether this theme negotiator should be used to set the theme.

Parameters
\Drupal\Core\Routing\RouteMatchInterface$route_matchThe current route match object.
Returns
bool TRUE if this negotiator should be used or FALSE to let other negotiators decide.
}

Implements ThemeNegotiatorInterface.

References RouteMatchInterface\getRouteObject().

Here is the call graph for this function:

determineActiveTheme ( RouteMatchInterface  $route_match)

{Determine the active theme for the request.

Parameters
\Drupal\Core\Routing\RouteMatchInterface$route_matchThe current route match object.
Returns
string|null Returns the active theme name, else return NULL.
}

Implements ThemeNegotiatorInterface.

References Drupal\configFactory(), and Drupal\requestStack().

Here is the call graph for this function:


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