class RouteSubscriber in Empty Front Page 8
Subscriber for Empty Front page routes.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\empty_front_page\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
1 service uses RouteSubscriber
File
- src/
Routing/ RouteSubscriber.php, line 17 - Contains \Drupal\empty_front_page\Routing\RouteSubscriber.
Namespace
Drupal\empty_front_page\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
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;
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
// Ensure to run after the views route subscriber.
// @see \Drupal\views\EventSubscriber
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
-180,
];
return $events;
}
/**
* Content callback.
*/
public static function content() {
return [
'#markup' => '',
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public static | function | Content callback. | |
RouteSubscriber:: |
public static | function |
Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase:: |
|
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |