You are here

protected function RouteSubscriber::alterRoutes in Theme permission 8

Same name and namespace in other branches
  1. 2.0.x src/Routing/RouteSubscriber.php \Drupal\theme_permission\Routing\RouteSubscriber::alterRoutes()

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 18

Class

RouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\theme_permission\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  if ($route = $collection
    ->get('block.admin_display_theme')) {
    $route
      ->setRequirement('_custom_access', '\\Drupal\\theme_permission\\Controller\\AccessController::access');
  }
  if ($route = $collection
    ->get('system.theme_settings_theme')) {
    $route
      ->setRequirement('_custom_access', '\\Drupal\\theme_permission\\Controller\\AccessController::access');
  }
  if ($route = $collection
    ->get('system.theme_set_default')) {
    $route
      ->setRequirement('_custom_access', '\\Drupal\\theme_permission\\Controller\\AccessController::access');
  }
  if ($route = $collection
    ->get('system.theme_install')) {
    $route
      ->setRequirement('_custom_access', '\\Drupal\\theme_permission\\Controller\\AccessController::access');
  }
  if ($route = $collection
    ->get('system.theme_uninstall')) {
    $route
      ->setRequirement('_custom_access', '\\Drupal\\theme_permission\\Controller\\AccessController::access');
  }
  if ($route = $collection
    ->get('system.themes_page')) {
    $route
      ->setDefaults([
      '_controller' => '\\Drupal\\theme_permission\\Controller\\AccessController::themesPage',
    ]);
  }
}