class AdminContext
Same name in other branches
- 9 core/lib/Drupal/Core/Routing/AdminContext.php \Drupal\Core\Routing\AdminContext
- 8.9.x core/lib/Drupal/Core/Routing/AdminContext.php \Drupal\Core\Routing\AdminContext
- 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.
Hierarchy
- class \Drupal\Core\Routing\AdminContext
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'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses AdminContext
File
-
core/
lib/ Drupal/ Core/ Routing/ AdminContext.php, line 10
Namespace
Drupal\Core\RoutingView 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
->getRouteObject();
if (!$route) {
return FALSE;
}
}
return (bool) $route->getOption('_admin_route');
}
}
Members
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.