You are here

class AllowedLanguagesRouteSubscriber in Allowed Languages 8

Same name and namespace in other branches
  1. 2.x src/Routing/AllowedLanguagesRouteSubscriber.php \Drupal\allowed_languages\Routing\AllowedLanguagesRouteSubscriber

Subscriber for entity translation routes.

Hierarchy

Expanded class hierarchy of AllowedLanguagesRouteSubscriber

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

File

src/Routing/AllowedLanguagesRouteSubscriber.php, line 12

Namespace

Drupal\allowed_languages\Routing
View source
class AllowedLanguagesRouteSubscriber extends ContentTranslationRouteSubscriber {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    foreach ($this->contentTranslationManager
      ->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
      if ($route = $collection
        ->get("entity.{$entity_type_id}.content_translation_overview")) {
        $route
          ->setDefault('_controller', '\\Drupal\\allowed_languages\\Controller\\AllowedLanguagesController::overview');
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {

    // Should run after ContentTranslationRouteSubscriber. Therefore priority -220.
    $events[RoutingEvents::ALTER] = [
      'onAlterRoutes',
      -220,
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AllowedLanguagesRouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides ContentTranslationRouteSubscriber::alterRoutes
AllowedLanguagesRouteSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. Overrides ContentTranslationRouteSubscriber::getSubscribedEvents
ContentTranslationRouteSubscriber::$contentTranslationManager protected property The content translation manager.
ContentTranslationRouteSubscriber::__construct public function Constructs a ContentTranslationRouteSubscriber object.
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1