class DenyAccessSubscriber in Acquia Content Hub 8.2
Restricts the access to the general media page.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\acquia_contenthub_preview\Routing\DenyAccessSubscriber
Expanded class hierarchy of DenyAccessSubscriber
1 string reference to 'DenyAccessSubscriber'
- acquia_contenthub_preview.services.yml in modules/
acquia_contenthub_preview/ acquia_contenthub_preview.services.yml - modules/acquia_contenthub_preview/acquia_contenthub_preview.services.yml
1 service uses DenyAccessSubscriber
- acquia_contenthub_preview.deny_access in modules/
acquia_contenthub_preview/ acquia_contenthub_preview.services.yml - Drupal\acquia_contenthub_preview\Routing\DenyAccessSubscriber
File
- modules/
acquia_contenthub_preview/ src/ Routing/ DenyAccessSubscriber.php, line 12
Namespace
Drupal\acquia_contenthub_preview\RoutingView source
class DenyAccessSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[RoutingEvents::ALTER][] = [
'onAlterRoutes',
-1001,
];
return $events;
}
/**
* Sets access permission to false on everything but the webhook.
*
* @param \Symfony\Component\Routing\RouteCollection $collection
* The collection of routes.
*/
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',
]);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DenyAccessSubscriber:: |
public | function |
Sets access permission to false on everything but the webhook. Overrides RouteSubscriberBase:: |
|
DenyAccessSubscriber:: |
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 |