You are here

public function DenyAccessSubscriber::alterRoutes in Acquia Content Hub 8.2

Sets access permission to false on everything but the webhook.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The collection of routes.

Overrides RouteSubscriberBase::alterRoutes

File

modules/acquia_contenthub_preview/src/Routing/DenyAccessSubscriber.php, line 28

Class

DenyAccessSubscriber
Restricts the access to the general media page.

Namespace

Drupal\acquia_contenthub_preview\Routing

Code

public function alterRoutes(RouteCollection $collection) {
  $allow_access = [
    'acquia_contenthub.webhook',
    'acquia_contenthub.admin_settings',
    'acquia_contenthub_preview.preview',
  ];
  foreach ($collection
    ->all() as $route_name => $route) {
    if (!in_array($route_name, $allow_access)) {
      $route
        ->setRequirements([
        '_access' => 'FALSE',
      ]);
    }
  }
}