RouteSubscriber.php in Empty Front Page 8
File
src/Routing/RouteSubscriber.php
View source
<?php
namespace Drupal\empty_front_page\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Drupal\Core\Routing\RoutingEvents;
use Symfony\Component\Routing\RouteCollection;
class RouteSubscriber extends RouteSubscriberBase {
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;
}
}
}
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
-180,
];
return $events;
}
public static function content() {
return [
'#markup' => '',
];
}
}