PHP Class eZ\Publish\Core\REST\Common\RequestParser\Pattern

Handles 2 types of patterns to be used in an URL: - {foo} matches anything but a slash and is used to match the typical URL variable (e.g. an ID) - {&foo} matches the slash, too, and is used to match only those URL variables, which may have a slash
Inheritance: implements eZ\Publish\Core\REST\Common\RequestParser
Show file Open project: ezsystems/ezpublish-kernel Class Usage Examples

Protected Properties

Property Type Description
$compileCache array Cache for compiled expressions.
$map array Map of URL types to their URL patterns.

Public Methods

Method Description
__construct ( array $map = [] ) Construct from optional initial map.
addPattern ( string $type, string $pattern ) Adds a pattern for a type.
generate ( string $type, array $values = [] ) : string Generate a URL of the given type from the specified values.
parse ( string $url ) : array Parse URL and return the IDs contained in the URL.
parseHref ( $href, $attribute )

Protected Methods

Method Description
compile ( string $pattern ) : string Compiles a given pattern to a PCRE regular expression.

Method Details

__construct() public method

Construct from optional initial map.
public __construct ( array $map = [] )
$map array

addPattern() public method

Adds a pattern for a type.
public addPattern ( string $type, string $pattern )
$type string
$pattern string

compile() protected method

Compiles a given pattern to a PCRE regular expression.
protected compile ( string $pattern ) : string
$pattern string
return string

generate() public method

Generate a URL of the given type from the specified values.
public generate ( string $type, array $values = [] ) : string
$type string
$values array
return string

parse() public method

Parse URL and return the IDs contained in the URL.
public parse ( string $url ) : array
$url string
return array

parseHref() public method

public parseHref ( $href, $attribute )

Property Details

$compileCache protected property

Cache for compiled expressions.
protected array $compileCache
return array

$map protected property

Map of URL types to their URL patterns.
protected array $map
return array