You are here

class TmgmtConfigRouteSubscriber in Translation Management Tool 8

Subscriber to alter entity translation routes.

Hierarchy

Expanded class hierarchy of TmgmtConfigRouteSubscriber

1 string reference to 'TmgmtConfigRouteSubscriber'
tmgmt_config.services.yml in sources/tmgmt_config/tmgmt_config.services.yml
sources/tmgmt_config/tmgmt_config.services.yml
1 service uses TmgmtConfigRouteSubscriber
tmgmt_config.subscriber in sources/tmgmt_config/tmgmt_config.services.yml
Drupal\tmgmt_config\Routing\TmgmtConfigRouteSubscriber

File

sources/tmgmt_config/src/Routing/TmgmtConfigRouteSubscriber.php, line 12

Namespace

Drupal\tmgmt_config\Routing
View source
class TmgmtConfigRouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {

    // Look for routes that use  ContentTranslationController and change it
    // to our subclass.
    foreach ($collection as $route) {
      if ($route
        ->getDefault('_controller') == '\\Drupal\\config_translation\\Controller\\ConfigTranslationController::itemPage') {
        $route
          ->setDefault('_controller', '\\Drupal\\tmgmt_config\\Controller\\ConfigTranslationControllerOverride::itemPage');
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events = parent::getSubscribedEvents();

    // \Drupal\config_translation\Routing\RouteSubscriber is -110,
    // make sure we are later.
    $events[RoutingEvents::ALTER] = array(
      'onAlterRoutes',
      -111,
    );
    return $events;
  }

}

Members

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