class CurrentPathStack (View source)

Represents the current path for the current request.

Note: You should not rely on paths but rather on route names / parameters or other indicators like context. For some fundamental parts, like routing or path processing, there is unfortunately no way around dealing with paths.

Properties

protected SplObjectStorage $paths

Static cache of paths.

protected RequestStack $requestStack

The request stack.

Methods

__construct(RequestStack $request_stack)

Constructs a new CurrentPathStack instance.

string
getPath(Request $request = NULL)

Returns the path of the current request.

$this
setPath(string $path, Request $request = NULL)

Sets the current path.

Details

__construct(RequestStack $request_stack)

Constructs a new CurrentPathStack instance.

Parameters

RequestStack $request_stack

The request stack.

string getPath(Request $request = NULL)

Returns the path of the current request.

Parameters

Request $request

(optional) The request.

Return Value

string

Returns the path, without leading slashes.

$this setPath(string $path, Request $request = NULL)

Sets the current path.

Parameters

string $path

The path.

Request $request

(optional) The request.

Return Value

$this