You are here

class GroupMenuRouteSubscriber in Group Menu 8

Modify form for config.sync route.

Hierarchy

Expanded class hierarchy of GroupMenuRouteSubscriber

1 string reference to 'GroupMenuRouteSubscriber'
groupmenu.services.yml in ./groupmenu.services.yml
groupmenu.services.yml
1 service uses GroupMenuRouteSubscriber
groupmenu.route_subscriber in ./groupmenu.services.yml
Drupal\groupmenu\Routing\GroupMenuRouteSubscriber

File

src/Routing/GroupMenuRouteSubscriber.php, line 11

Namespace

Drupal\groupmenu\Routing
View source
class GroupMenuRouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    $routes = $collection
      ->all();
    foreach ($routes as $route_name => $route) {
      switch ($route_name) {
        case 'entity.menu.edit_form':
        case 'entity.menu.add_link_form':
          $route
            ->setRequirements([
            '_custom_access' => '\\Drupal\\groupmenu\\Access\\GroupMenuAccess::menuEditAccess',
          ]);
          break;
        case 'entity.menu.delete_form':
          $route
            ->setRequirements([
            '_custom_access' => '\\Drupal\\groupmenu\\Access\\GroupMenuAccess::menuDeleteAccess',
          ]);
          break;
        case 'menu_ui.link_edit':
        case 'menu_ui.link_reset':
          $route
            ->setRequirements([
            '_custom_access' => '\\Drupal\\groupmenu\\Access\\GroupMenuAccess::menuLinkAccess',
          ]);
          break;
        case 'entity.menu_link_content.canonical':
        case 'entity.menu_link_content.delete_form':
          $route
            ->setRequirements([
            '_custom_access' => '\\Drupal\\groupmenu\\Access\\GroupMenuAccess::menuItemAccess',
          ]);
          break;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GroupMenuRouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1