class AjaxBasePageNegotiator

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.

Hierarchy

File

core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php, line 27

Namespace

Drupal\Core\Theme

Members

Name Modifiers Type Description
AjaxBasePageNegotiator::$configFactory protected property The config factory.
AjaxBasePageNegotiator::$csrfGenerator protected property The CSRF token generator.
AjaxBasePageNegotiator::$requestStack protected property The request stack.
AjaxBasePageNegotiator::applies public function Whether this theme negotiator should be used to set the theme. Overrides ThemeNegotiatorInterface::applies
AjaxBasePageNegotiator::determineActiveTheme public function Determine the active theme for the request. Overrides ThemeNegotiatorInterface::determineActiveTheme
AjaxBasePageNegotiator::__construct public function Constructs a new AjaxBasePageNegotiator.

© 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!Theme!AjaxBasePageNegotiator.php/class/AjaxBasePageNegotiator/8.1.x