3 namespace Drupal\Core\Routing;
5 use Symfony\Component\Routing\Route;
8 * Provides a helper class to determine whether the route is an admin one.
15 * @var \Drupal\Core\Routing\RouteMatchInterface
17 protected $routeMatch;
20 * Construct a new admin context helper instance.
22 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
25 public function __construct(RouteMatchInterface $route_match) {
26 $this->routeMatch = $route_match;
30 * Determines whether the active route is an admin one.
32 * @param \Symfony\Component\Routing\Route $route
33 * (optional) The route to determine whether it is an admin one. Per default
34 * this falls back to the route object on the active request.
37 * Returns TRUE if the route is an admin one, otherwise FALSE.
39 public function isAdminRoute(Route $route = NULL) {
41 $route = $this->routeMatch->getRouteObject();
46 return (bool) $route->getOption('_admin_route');