You are here

class TmgmtContentRouteSubscriber in Translation Management Tool 8

Subscriber to alter entity translation routes.

Hierarchy

Expanded class hierarchy of TmgmtContentRouteSubscriber

1 string reference to 'TmgmtContentRouteSubscriber'
tmgmt_content.services.yml in sources/content/tmgmt_content.services.yml
sources/content/tmgmt_content.services.yml
1 service uses TmgmtContentRouteSubscriber
tmgmt_content.subscriber in sources/content/tmgmt_content.services.yml
Drupal\tmgmt_content\Routing\TmgmtContentRouteSubscriber

File

sources/content/src/Routing/TmgmtContentRouteSubscriber.php, line 12

Namespace

Drupal\tmgmt_content\Routing
View source
class TmgmtContentRouteSubscriber 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\\content_translation\\Controller\\ContentTranslationController::overview') {
        $route
          ->setDefault('_controller', '\\Drupal\\tmgmt_content\\Controller\\ContentTranslationControllerOverride::overview');
      }
    }
  }

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

    //  ContentTranslationRouteSubscriber is -100, make sure we are later.
    $events[RoutingEvents::ALTER] = array(
      'onAlterRoutes',
      -211,
    );
    return $events;
  }

}

Members

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