diff --git a/src/Application/LinkGenerator.php b/src/Application/LinkGenerator.php index 122fdfc7b..3c89ffea7 100644 --- a/src/Application/LinkGenerator.php +++ b/src/Application/LinkGenerator.php @@ -12,7 +12,7 @@ use Nette\Http\UrlScript; use Nette\Routing\Router; use Nette\Utils\Reflection; -use function array_intersect_key, array_key_exists, http_build_query, is_string, is_subclass_of, parse_str, preg_match, rtrim, str_contains, str_ends_with, strcasecmp, strlen, strncmp, strtr, substr, trigger_error, urldecode; +use function array_intersect_key, array_key_exists, http_build_query, in_array, is_string, is_subclass_of, parse_str, preg_match, rtrim, str_contains, str_ends_with, strcasecmp, strlen, strncmp, strtr, substr, trigger_error, urldecode; /** @@ -299,7 +299,7 @@ private function validateLinkTarget( string $mode, ): void { - if ($mode !== 'forward' && !(new UI\AccessPolicy($element))->isLinkable()) { + if (!in_array($mode, ['test', 'forward']) && !(new UI\AccessPolicy($element))->isLinkable()) { throw new UI\InvalidLinkException("Link to forbidden $message from '{$presenter->getName()}:{$presenter->getAction()}'."); } elseif ($presenter?->invalidLinkMode && (UI\ComponentReflection::parseAnnotation($element, 'deprecated') || $element->getAttributes(Attributes\Deprecated::class))