RouteSubscriber.php in Varbase Total Control Dashboard 9.0.x
File
src/Routing/RouteSubscriber.php
View source
<?php
namespace Drupal\varbase_total_control\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
use Drupal\Core\Routing\RoutingEvents;
class RouteSubscriber extends RouteSubscriberBase {
protected function alterRoutes(RouteCollection $collection) {
if ($route = $collection
->get('page_manager.page_view_total_control_dashboard_total_control_dashboard-panels_variant-0')) {
$route
->setRequirement('_permission', 'have total control');
}
if ($route = $collection
->get('page_manager.page_view_total_control_dashboard_total_control_dashboard-panels_variant-1')) {
$route
->setRequirement('_permission', 'have total control');
}
}
public static function getSubscribedEvents() {
$events[RoutingEvents::ALTER][] = [
'onAlterRoutes',
-170,
];
return $events;
}
}