class AdminContext in Drupal 8
Same name and namespace in other branches
- 9 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AdminContext:: |
protected | property | The route match. | |
AdminContext:: |
public | function | Determines whether the active route is an admin one. | |
AdminContext:: |
public | function | Construct a new admin context helper instance. |