Created
April 18, 2024 13:08
-
-
Save vyspiansky/c842f7702bce81f92968ffe80a79b96d to your computer and use it in GitHub Desktop.
Drupal: return a 403 response from a controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\your_module\Controller; | |
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | |
class YourController { | |
public function yourPage() { | |
// Some logic here... | |
if (!$access) { | |
throw new AccessDeniedHttpException(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment