public function SimpleMegaMenuAccessCanonicalPageSubscriber::onRequestCheckAccess in Simple Mega Menu 8
Same name and namespace in other branches
- 2.0.x src/EventSubscriber/SimpleMegaMenuAccessCanonicalPageSubscriber.php \Drupal\simple_megamenu\EventSubscriber\SimpleMegaMenuAccessCanonicalPageSubscriber::onRequestCheckAccess()
This method is called whenever the kernel.request event is dispatched.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The event object.
File
- src/
EventSubscriber/ SimpleMegaMenuAccessCanonicalPageSubscriber.php, line 53
Class
- SimpleMegaMenuAccessCanonicalPageSubscriber
- Class SimpleMegaMenuAccessCanonicalPageSubscriber.
Namespace
Drupal\simple_megamenu\EventSubscriberCode
public function onRequestCheckAccess(GetResponseEvent $event) {
$request = $event
->getRequest();
// If we've got an exception, nothing to do here.
if ($request
->get('exception') != NULL) {
return;
}
/** @var \Drupal\simple_megamenu\Entity\SimpleMegaMenu $simple_mega_menu */
$simple_mega_menu = $request
->get('simple_mega_menu');
if ($simple_mega_menu && $simple_mega_menu instanceof SimpleMegaMenuInterface) {
if (!$this->currentUser
->hasPermission('access simple mega menu entities canonical page')) {
throw new NotFoundHttpException();
}
}
}