You are here

class RouteSubscriber in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Routing/RouteSubscriber.php \Drupal\opigno_module\Routing\RouteSubscriber

Listens to the dynamic route events.

Hierarchy

Expanded class hierarchy of RouteSubscriber

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

File

src/Routing/RouteSubscriber.php, line 11

Namespace

Drupal\opigno_module\Routing
View source
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection
      ->get('entity.opigno_module.collection')) {
      $route
        ->setPath('/admin/structure/opigno-modules');
    }
    if ($route = $collection
      ->get('entity.opigno_activity.collection')) {
      $route
        ->setPath('/admin/structure/opigno-activities');
    }
    if ($route = $collection
      ->get('entity.group.collection')) {
      $route
        ->setPath('/admin/structure/groups');
    }
    if ($route = $collection
      ->get('private_message.private_message_page')) {
      $route
        ->setDefault('_title', 'Discussion threads');
    }

    // Rewrite permissions for Drupal\entity_browser\Entity\EntityBrowser::route() to allow group content manager add an image to a module
    if ($route = $collection
      ->get('entity_browser.media_entity_browser_groups')) {
      $route
        ->setRequirements([
        '_custom_access' => '\\Drupal\\opigno_module\\Controller\\OpignoModuleController::accessEntityBrowserGroups',
      ]);
    }

    // H5P libraries list.
    if ($route = $collection
      ->get('h5peditor.content_type_cache')) {
      $route
        ->setDefaults(array(
        '_controller' => '\\Drupal\\opigno_module\\Controller\\OpignoH5PEditorAJAXController::contentTypeCacheCallback',
      ));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::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