Misc functions

hasPermission
createCsrfToken
isValidCsrfToken
generateURL
generateStaticURL
isSafeMethod
hasResponseParameter
wrapTurbo

hasPermission

Checks if the current user/request has permission to access the route.

Compares the request method against allowed methods and user groups
against allowed access groups configured in the route.

@return bool True if permission is granted, false otherwise

hasPermission(): bool

createCsrfToken

Creates a CSRF token for the current path, stores it in user session and response parameters.

@return string Generated CSRF token string

createCsrfToken(): string

isValidCsrfToken

Validates a CSRF token against the stored token in user session or response parameters.

@param string $csrfToken Token to validate
@return bool True if valid, false otherwise

isValidCsrfToken(string $csrfToken): bool

generateURL

Generates a fully qualified URL for the current route with optional query parameters and fragment.

Uses TYPO3 site's router if available, falls back to static URL generation.

@param array $queryParams Additional query parameters to include in the URL
@param string $fragment Optional URL fragment to append
@param string $type URI type, per RouterInterface constants (default ABSOLUTE_URL)
@return string Generated URL string

generateURL(array $queryParams = [], string $fragment = '', string $type = RouterInterface::ABSOLUTE_URL): string

generateStaticURL

Generates a static URL string for a given path, query parameters, and fragment.

Queries the database for page UID and generates URI using TYPO3 PageRouter.

@param string $path Path for which to generate the URL
@param array $queryParams Optional query parameters
@param string $fragment Optional URL fragment
@param string $type URI type per RouterInterface constants (default ABSOLUTE_URL)
@return string Generated URL string

generateStaticURL(
	string $path,
	array $queryParams = [],
	string $fragment = '',
	string $type = RouterInterface::ABSOLUTE_URL
): string
ConstantDefinition
RouterInterface::ABSOLUTE_URL = 'url'Generates an absolute URL
RouterInterface::ABSOLUTE_PATH = 'absolute'Generates an absolute path

isSafeMethod

Checks if the current HTTP method is considered safe as per RFC 9110.

Safe methods are: GET, HEAD, OPTIONS, TRACE.

@return bool True if method is safe, false otherwise

isSafeMethod(): bool

hasResponseParameter

Checks whether a response parameter with the given key exists.

@param string $key Parameter key
@return bool True if the parameter exists, false otherwise

hasResponseParameter(string $key): bool

wrapTurbo

Wraps the response body content inside Turbo Stream or Turbo Frame elements depending on the turbo settings from the route attribute.

Updates the cache content with the wrapped body.

@return void

wrapTurbo(): void