You are here

RouteSubscriber.php in Theme permission 8

Same filename and directory in other branches
  1. 2.0.x src/Routing/RouteSubscriber.php

File

src/Routing/RouteSubscriber.php
View source
<?php

declare (strict_types=1);
namespace Drupal\theme_permission\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  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',
      ]);
    }
  }

}

Classes

Namesort descending Description
RouteSubscriber Listens to the dynamic route events.