Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
eZ\Publish\Core\REST\Common\RequestParser\Pattern Class Reference

Pattern based Request parser. More...

Inheritance diagram for eZ\Publish\Core\REST\Common\RequestParser\Pattern:

## Public Member Functions
| __construct (array $map=[])
| Construct from optional initial map. More...
| addPattern ($type, $pattern)
| Adds a pattern for a type. More...
| parse ($url)
| Parse URL and return the IDs contained in the URL. More...
| generate ($type, array $values=[])
| Generate a URL of the given type from the specified values. More...
| parseHref ($href, $attribute)
| Tries to match $href as a route, and returns the value of $attribute from the result. More...

## Public Attributes
const | STANDARD_VARIABLE_REGEX = '\{([A-Za-z-_]+)\}'
| Pattern regular sub-expression. More...
const | SLASHES_VARIABLE_REGEX = '\{(?:\&\s*)([A-Za-z-_]+)\}'
| Pattern regular sub-expression that might contain slashes. More...

## Protected Member Functions
| compile ($pattern)
| Compiles a given pattern to a PCRE regular expression. More...

## Protected Attributes
| $map = []
| $compileCache = []

## Detailed Description

Pattern based Request parser.

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

Definition at line 22 of file Core/REST/Common/RequestParser/Pattern.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZ\Publish\Core\REST\Common\RequestParser\Pattern::__construct | ( | array | $map = `[]` | ) |

Construct from optional initial map.

Parameters

  array | $map |

Definition at line 53 of file Core/REST/Common/RequestParser/Pattern.php.

References eZ\Publish\Core\REST\Common\RequestParser\Pattern\$map, and eZ\Publish\Core\REST\Common\RequestParser\Pattern\addPattern().

## Member Function Documentation

## ◆ addPattern()

eZ\Publish\Core\REST\Common\RequestParser\Pattern::addPattern | ( |  | $type,
|  |  | $pattern
| ) |  |

Adds a pattern for a type.

Parameters

  string | $type |
  string | $pattern |

Definition at line 66 of file Core/REST/Common/RequestParser/Pattern.php.

Referenced by eZ\Publish\Core\REST\Common\RequestParser\Pattern\__construct().

## ◆ compile()

eZ\Publish\Core\REST\Common\RequestParser\Pattern::compile | ( |  | $pattern | ) |
| protected

Compiles a given pattern to a PCRE regular expression.

Parameters

  string | $pattern |

Returns
  string

Definition at line 106 of file Core/REST/Common/RequestParser/Pattern.php.

Referenced by eZ\Publish\Core\REST\Common\RequestParser\Pattern\parse().

## ◆ generate()

eZ\Publish\Core\REST\Common\RequestParser\Pattern::generate | ( |  | $type,
|  | array | $values = `[]`
| ) |  |

Generate a URL of the given type from the specified values.

Parameters

  string | $type |
  array | $values |

Returns
  string

Implements eZ\Publish\Core\REST\Common\RequestParser.

Definition at line 151 of file Core/REST/Common/RequestParser/Pattern.php.

## ◆ parse()

eZ\Publish\Core\REST\Common\RequestParser\Pattern::parse | ( |  | $url | ) |

Parse URL and return the IDs contained in the URL.

Parameters

  string | $type |
  string | $url |

Returns
  array

Implements eZ\Publish\Core\REST\Common\RequestParser.

Definition at line 80 of file Core/REST/Common/RequestParser/Pattern.php.

References eZ\Publish\Core\REST\Common\RequestParser\Pattern\compile().

Referenced by eZ\Publish\Core\REST\Common\RequestParser\Pattern\parseHref().

## ◆ parseHref()

eZ\Publish\Core\REST\Common\RequestParser\Pattern::parseHref | ( |  | $href,
|  |  | $attribute
| ) |  |

Tries to match $href as a route, and returns the value of $attribute from the result.

Parameters

  string | $href |
  string | $attribute |

Returns
  mixed|false

Implements eZ\Publish\Core\REST\Common\RequestParser.

Definition at line 181 of file Core/REST/Common/RequestParser/Pattern.php.

References eZ\Publish\Core\REST\Common\RequestParser\Pattern\parse().

## Member Data Documentation

## ◆ $compileCache

eZ\Publish\Core\REST\Common\RequestParser\Pattern::$compileCache = []
| protected

Definition at line 36 of file Core/REST/Common/RequestParser/Pattern.php.

## ◆ $map

eZ\Publish\Core\REST\Common\RequestParser\Pattern::$map = []
| protected

Definition at line 29 of file Core/REST/Common/RequestParser/Pattern.php.

Referenced by eZ\Publish\Core\REST\Common\RequestParser\Pattern\__construct().

## ◆ SLASHES_VARIABLE_REGEX

const eZ\Publish\Core\REST\Common\RequestParser\Pattern::SLASHES_VARIABLE_REGEX = '\{(?:\&\s*)([A-Za-z-_]+)\}'

Pattern regular sub-expression that might contain slashes.

Definition at line 46 of file Core/REST/Common/RequestParser/Pattern.php.

## ◆ STANDARD_VARIABLE_REGEX

const eZ\Publish\Core\REST\Common\RequestParser\Pattern::STANDARD_VARIABLE_REGEX = '\{([A-Za-z-_]+)\}'

Pattern regular sub-expression.

Definition at line 41 of file Core/REST/Common/RequestParser/Pattern.php.

The documentation for this class was generated from the following file:

- Core/REST/Common/RequestParser/Pattern.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.