You are here

protected function RouteSubscriber::alterRoutes in Translation Management Tool 8

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

translators/tmgmt_local/src/Routing/RouteSubscriber.php, line 34

Class

RouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\tmgmt_local\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  if ($collection
    ->get('tmgmt.admin_tmgmt')) {
    $route = $collection
      ->get('tmgmt.admin_tmgmt');
    $route
      ->addRequirements([
      '_permission' => $collection
        ->get('tmgmt.admin_tmgmt')
        ->getRequirement('_permission') . '+administer translation tasks+provide translation services',
    ]);
  }
  foreach ($collection
    ->all() as $route) {
    if (strpos($route
      ->getPath(), '/translate') === 0 && $this->configFactory
      ->get('tmgmt_local.settings')
      ->get('use_admin_theme') || strpos($route
      ->getPath(), '/manage-translate') === 0) {
      $route
        ->setOption('_admin_route', TRUE);
    }
  }
}