Documentation

RoutingExtension extends AbstractExtension
in package

FinalYes

Provides integration of the Routing component with Twig.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

Properties

$generator  : mixed

Methods

__construct()  : mixed
getFilters()  : array<string|int, TwigFilter>
Returns a list of filters to add to the existing list.
getFunctions()  : array<string|int, TwigFunction>
Returns a list of functions to add to the existing list.
getNodeVisitors()  : array<string|int, NodeVisitorInterface>
Returns the node visitor instances to add to the existing list.
getOperators()  : array<string|int, array<string|int, mixed>>
Returns a list of operators to add to the existing list.
getPath()  : string
getTests()  : array<string|int, TwigTest>
Returns a list of tests to add to the existing list.
getTokenParsers()  : array<string|int, TokenParserInterface>
Returns the token parser instances to add to the existing list.
getUrl()  : string
isUrlGenerationSafe()  : array<string|int, mixed>
Determines at compile time whether the generated URL will be safe and thus saving the unneeded automatic escaping for performance reasons.

Properties

Methods

getOperators()

Returns a list of operators to add to the existing list.

public getOperators() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>

First array of unary operators, second array of binary operators

getPath()

public getPath(string $name[, array<string|int, mixed> $parameters = [] ][, bool $relative = false ]) : string
Parameters
$name : string
$parameters : array<string|int, mixed> = []
$relative : bool = false
Return values
string

getUrl()

public getUrl(string $name[, array<string|int, mixed> $parameters = [] ][, bool $schemeRelative = false ]) : string
Parameters
$name : string
$parameters : array<string|int, mixed> = []
$schemeRelative : bool = false
Return values
string

isUrlGenerationSafe()

Determines at compile time whether the generated URL will be safe and thus saving the unneeded automatic escaping for performance reasons.

public isUrlGenerationSafe(Node $argsNode) : array<string|int, mixed>

The URL generation process percent encodes non-alphanumeric characters. So there is no risk that malicious/invalid characters are part of the URL. The only character within an URL that must be escaped in html is the ampersand ("&") which separates query params. So we cannot mark the URL generation as always safe, but only when we are sure there won't be multiple query params. This is the case when there are none or only one constant parameter given. E.g. we know beforehand this will be safe:

  • path('route')
  • path('route', {'param': 'value'}) But the following may not:
  • path('route', var)
  • path('route', {'param': ['val1', 'val2'] }) // a sub-array
  • path('route', {'param1': 'value1', 'param2': 'value2'}) If param1 and param2 reference placeholder in the route, it would still be safe. But we don't know.
Parameters
$argsNode : Node

The arguments of the path/url function

Return values
array<string|int, mixed>

An array with the contexts the URL is safe


        
On this page

Search results