public function onRouteBuildAlter(RouteBuildEvent $event) {
    $collection = $event->getRouteCollection();
    array_walk(static::$disabledRoutes, function ($disabledRouteName) use ($collection) {
      if ($route = $collection->get($disabledRouteName)) {
        $route->setRequirement('_access', 'FALSE');
      }
    });
  }
public function onRouteBuildAlter(RouteBuildEvent $event) {
    $collection = $event->getRouteCollection();
    array_walk(static::$disabledRoutes, function ($disabledRouteName) use ($collection) {
      if ($route = $collection->get($disabledRouteName)) {
        $route->setRequirement('_access', 'FALSE');
      }
    });
  }
public function onRouteBuildAlter ( RouteBuildEvent $ event ) { $ collection = $ event -> getRouteCollection ( ) ; array_walk ( static :: $ disabledRoutes , function ( $ disabledRouteName ) use ( $ collection ) { if ( $ route = $ collection -> get ( $ disabledRouteName ) ) { $ route -> setRequirement ( '_access' , 'FALSE' ) ; } } ) ; }
Hides routes by denying access to them.

@param \Drupal\Core\Routing\RouteBuildEvent $event
Hides routes by denying access to them .