function ToolbarController::subtreesAjax
Same name in other branches
- 9 core/modules/toolbar/src/Controller/ToolbarController.php \Drupal\toolbar\Controller\ToolbarController::subtreesAjax()
- 8.9.x core/modules/toolbar/src/Controller/ToolbarController.php \Drupal\toolbar\Controller\ToolbarController::subtreesAjax()
- 11.x core/modules/toolbar/src/Controller/ToolbarController.php \Drupal\toolbar\Controller\ToolbarController::subtreesAjax()
Returns an AJAX response to render the toolbar subtrees.
Return value
\Drupal\Core\Ajax\AjaxResponse
1 string reference to 'ToolbarController::subtreesAjax'
- toolbar.routing.yml in core/
modules/ toolbar/ toolbar.routing.yml - core/modules/toolbar/toolbar.routing.yml
File
-
core/
modules/ toolbar/ src/ Controller/ ToolbarController.php, line 40
Class
- ToolbarController
- Defines a controller for the toolbar module.
Namespace
Drupal\toolbar\ControllerCode
public function subtreesAjax() {
[
$subtrees,
] = toolbar_get_rendered_subtrees();
$response = new AjaxResponse();
$response->addCommand(new SetSubtreesCommand($subtrees));
// The Expires HTTP header is the heart of the client-side HTTP caching. The
// additional server-side page cache only takes effect when the client
// accesses the callback URL again (e.g., after clearing the browser cache
// or when force-reloading a Drupal page).
$max_age = 365 * 24 * 60 * 60;
$response->setPrivate();
$response->setMaxAge($max_age);
$expires = new \DateTime();
$expires->setTimestamp($this->time
->getRequestTime() + $max_age);
$response->setExpires($expires);
return $response;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.