'onRequest', ]; } /** * React to a config object being saved. */ public function onRequest(RequestEvent $event) { $user = \Drupal::currentUser(); $user_roles = $user->getRoles(); if (!in_array('anonymous', $user_roles)) { return; } $current_request = \Drupal::requestStack()->getCurrentRequest(); $path = \Drupal::request()->getRequestUri(); if (str_contains($path, '/node/')) { throw new NotFoundHttpException(); } } }