You are here

protected function RouteSubscriber::alterRoutes in Empty Front Page 8

Alters existing routes for a specific collection.

Parameters

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

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 22
Contains \Drupal\empty_front_page\Routing\RouteSubscriber.

Class

RouteSubscriber
Subscriber for Empty Front page routes.

Namespace

Drupal\empty_front_page\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  $front_page = \Drupal::config('system.site')
    ->get('page.front');
  foreach ($collection as $route) {
    if ($route
      ->getPath() == '/' . $front_page) {
      $route
        ->setDefaults([
        '_content' => [
          $this,
          'content',
        ],
      ]);
      break;
    }
  }
}