diff --git a/src/Application/Attributes/AllowedFor.php b/src/Application/Attributes/AllowedFor.php new file mode 100644 index 000000000..5779f2c6d --- /dev/null +++ b/src/Application/Attributes/AllowedFor.php @@ -0,0 +1,21 @@ +getPresenter()->detectedCsrf(); } + + if ($attrs = $element->getAttributes(Nette\Application\Attributes\AllowedFor::class)) { + $method = strtolower($this->getPresenter()->getRequest()->getMethod()); + if (empty($attrs[0]->newInstance()->$method)) { + throw new Nette\Application\BadRequestException("Method '$method' is not allowed."); + } + } }