Adjusting node access module handler.
This commit is contained in:
parent
18cb2c1a8b
commit
8943bc06f5
@ -7,7 +7,6 @@
|
|||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class EntityTypeSubscriber.
|
* Class EntityTypeSubscriber.
|
||||||
*
|
*
|
||||||
@ -21,7 +20,7 @@ class KernelRequestNodePathCheck implements EventSubscriberInterface {
|
|||||||
* @return array
|
* @return array
|
||||||
* The event names to listen for, and the methods that should be executed.
|
* The event names to listen for, and the methods that should be executed.
|
||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents() {
|
public static function getSubscribedEvents(): array {
|
||||||
return [
|
return [
|
||||||
KernelEvents::REQUEST => 'onRequest',
|
KernelEvents::REQUEST => 'onRequest',
|
||||||
];
|
];
|
||||||
@ -30,7 +29,7 @@ public static function getSubscribedEvents() {
|
|||||||
/**
|
/**
|
||||||
* React to a config object being saved.
|
* React to a config object being saved.
|
||||||
*/
|
*/
|
||||||
public function onRequest(RequestEvent $event) {
|
public function onRequest(RequestEvent $event): void {
|
||||||
$user = \Drupal::currentUser();
|
$user = \Drupal::currentUser();
|
||||||
$user_roles = $user->getRoles();
|
$user_roles = $user->getRoles();
|
||||||
if (!in_array('anonymous', $user_roles)) {
|
if (!in_array('anonymous', $user_roles)) {
|
||||||
@ -39,7 +38,7 @@ public function onRequest(RequestEvent $event) {
|
|||||||
$current_request = \Drupal::requestStack()->getCurrentRequest();
|
$current_request = \Drupal::requestStack()->getCurrentRequest();
|
||||||
$path = \Drupal::request()->getRequestUri();
|
$path = \Drupal::request()->getRequestUri();
|
||||||
if (str_contains($path, '/node/')) {
|
if (str_contains($path, '/node/')) {
|
||||||
/* throw new AccessDeniedHttpException(); */
|
throw new AccessDeniedHttpException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user