Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 10 |
| AdminContext | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 10 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| isAdminRoute | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 8 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\Core\Routing\AdminContext. | |
| */ | |
| namespace Drupal\Core\Routing; | |
| use Symfony\Component\Routing\Route; | |
| /** | |
| * Provides a helper class to determine whether the route is an admin one. | |
| */ | |
| 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'); | |
| } | |
| } |