class PathTemplate implements ResourceTemplateInterface (View source)

Represents a path template.

Templates use the syntax of the API platform; see the protobuf of HttpRule for details. A template consists of a sequence of literals, wildcards, and variable bindings, where each binding can have a sub-path. A string representation can be parsed into an instance of PathTemplate, which can then be used to perform matching and instantiation.

Methods

__construct(string $path)

PathTemplate constructor.

string
__toString()

No description

string
render(array $bindings)

Renders a path template using the provided bindings.

bool
matches(string $path)

Check if $path matches a resource string.

array
match(string $path)

Matches a fully qualified path template string.

Details

__construct(string $path)

PathTemplate constructor.

Parameters

string $path A path template string

Exceptions

ValidationException When $path cannot be parsed into a valid PathTemplate

string __toString()

Return Value

string A string representation of the resource template

string render(array $bindings)

Renders a path template using the provided bindings.

Parameters

array $bindings An array matching var names to binding strings.

Return Value

string A rendered representation of this resource template.

Exceptions

ValidationException if a key isn't provided or if a sub-template can't be parsed.

bool matches(string $path)

Check if $path matches a resource string.

Parameters

string $path A resource string.

Return Value

bool

array match(string $path)

Matches a fully qualified path template string.

Parameters

string $path A resource string.

Return Value

array Array matching var names to binding values.

Exceptions

ValidationException if path can't be matched to the template.