class AdminContext

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Routing/AdminContext.php \Drupal\Core\Routing\AdminContext
  2. 10 core/lib/Drupal/Core/Routing/AdminContext.php \Drupal\Core\Routing\AdminContext
  3. 11.x core/lib/Drupal/Core/Routing/AdminContext.php \Drupal\Core\Routing\AdminContext

Provides a helper class to determine whether the route is an admin one.


Expanded class hierarchy of AdminContext

5 files declare their use of AdminContext
AdminNegotiator.php in core/modules/user/src/Theme/AdminNegotiator.php
AdminNegotiatorTest.php in core/modules/user/tests/src/Unit/Theme/AdminNegotiatorTest.php
AdminPathConfigEntityConverter.php in core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php
LanguageNegotiationUserAdmin.php in core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php
ViewUIConverter.php in core/modules/views_ui/src/ParamConverter/ViewUIConverter.php
1 string reference to 'AdminContext' in core/
1 service uses AdminContext
router.admin_context in core/


core/lib/Drupal/Core/Routing/AdminContext.php, line 10


View source
class AdminContext {
     * The route match.
     * @var \Drupal\Core\Routing\RouteMatchInterface
    protected $routeMatch;
     * Construct a new admin context helper instance.
     * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
     *   The route match.
    public function __construct(RouteMatchInterface $route_match) {
        $this->routeMatch = $route_match;
     * Determines whether the active route is an admin one.
     * @param \Symfony\Component\Routing\Route $route
     *   (optional) The route to determine whether it is an admin one. Per default
     *   this falls back to the route object on the active request.
     * @return bool
     *   Returns TRUE if the route is an admin one, otherwise FALSE.
    public function isAdminRoute(Route $route = NULL) {
        if (!$route) {
            $route = $this->routeMatch
            if (!$route) {
                return FALSE;
        return (bool) $route->getOption('_admin_route');



Title Sort descending Modifiers Object type Summary
AdminContext::$routeMatch protected property The route match.
AdminContext::isAdminRoute public function Determines whether the active route is an admin one.
AdminContext::__construct public function Construct a new admin context helper instance.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.