\phpDocumentor\Transformer\RouterRule

Summary

Methods
Properties
Constants
__construct()
match()
generate()
No public properties found
No constants found
translateToUrlEncodedPath()
$generator
$matcher
N/A
No private methods found
No private properties found
N/A

Properties

$generator

$generator : callable

Type

callable

$matcher

$matcher : callable

Type

callable

Methods

__construct()

__construct(callable  $matcher, callable  $generator) 

Initializes this rule.

Parameters

callable $matcher

A closure that returns a boolean indicating whether this rule applies to the provided node.

callable $generator

A closure that returns a url or null for the given node.

match()

match(string|\phpDocumentor\Descriptor\DescriptorAbstract  $node) : boolean

Returns true when this rule is applicable to the given node.

The contents of $node MAY be changed so that later rules in a router can try to match the changed value. An example of this is a string matcher that converts a provided FQSEN to a Descriptor so that Descriptor matchers in subsequent rules can generate a URL for it.

Parameters

string|\phpDocumentor\Descriptor\DescriptorAbstract $node

Returns

boolean

generate()

generate(string|\phpDocumentor\Descriptor\DescriptorAbstract  $node) : string|false

Generates an URL for the given node.

Parameters

string|\phpDocumentor\Descriptor\DescriptorAbstract $node

The node for which to generate an URL.

Returns

string|false —

a well-formed relative or absolute URL, or false if no URL could be generated.

translateToUrlEncodedPath()

translateToUrlEncodedPath(string  $generatedPathAsUtf8) : string

Translates the provided path, with UTF-8 characters, into a web- and windows-safe variant.

Windows does not support the use of UTF-8 characters on their file-system. In order to be sure that both the web and windows can support the given filename we decode the UTF-8 characters and then url encode them so that they will be plain characters that are suitable for the web.

If an anchor is found in the path, then it is neither url_encoded not transliterated because it should not result in a filename (otherwise another part of the application has made an error) but may be used during rendering of templates.

Parameters

string $generatedPathAsUtf8

Returns

string