kernel/classes/eznamepatternresolver.php
File containing the eZNamePatternResolver class
- Copyright
- Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
- License
- eZ Proprietary Use License v1.0
- Package
- kernel
- Version
- 4.5.0
\eZNamePatternResolver
eZNamePatternResolver is a utility class for resolving object name and url alias patterns.
This code supports object name pattern groups.
Syntax:
<attribute_identifier>
<attribute_identifier> <2nd-identifier>
User text <attribute_identifier>|(<2nd-identifier><3rd-identifier>)
Example:
<nickname|(<firstname> <lastname>)>
Tokens are looked up from left to right. If a match is found for the leftmost token, the 2nd token will not be used. Tokens are representations of attributes. So a match means that that the current attribute has data.
tokens are the class attribute identifiers which are used in the class edit-interface.
- Version
- 4.5.0
Properties

\array(string=>string)
$attributeArray= ''
Holds data fetched from content object attributes
- Type
- \array(string=>string)

\eZContentObject
$contentObject= ''
The content object which holds the attributes used to resolve name pattern.
- Type
- \eZContentObject

string
$metaString= ''EZMETAGROUP_''
The string to use to signify group tokens.
'EZMETAGROUP_'Details- Type
- string

string
$namePattern= ''
Holds the filtered name pattern where token groups are replaced with meta strings
- Type
- string

string
$translation= ''
Contains the language locale for which to fetch attributes.
- Type
- string
Methods

__construct(
string $namePattern, \eZContentObject $contentObject, int | false $contentVersion
=
false, string | false $contentTranslation
=
false
)
:
voidConstructs a object to resolve $namePattern. $contentVersion and $contentTranslation specify which version and translation respectively of the content object to use.
| Name | Type | Description |
|---|---|---|
| $namePattern | string | |
| $contentObject | \eZContentObject | |
| $contentVersion | int | false | |
| $contentTranslation | string | false |

extractTokens(
string $namePattern
)
:
arrayExtract all tokens from $namePattern
Example:
Text <token> more text ==> <token>
| Name | Type | Description |
|---|---|---|
| $namePattern | string |
| Type | Description |
|---|---|
| array |

fetchContentAttributes(
)
:
voidFetches the list of available class-identifiers in the token, and it will only fetch the attributes which appear amongst the identifiers found in tokens.

filterNamePattern(
string $namePattern
)
:
stringBuilds a lookup / translation table for groups in the $namePattern.
The groups are referenced with a generated meta-token in the original name pattern.
Returns intermediate name pattern where groups are replaced with meta- tokens.
| Name | Type | Description |
|---|---|---|
| $namePattern | string |
| Type | Description |
|---|---|
| string |

getIdentifiers(
string $patternString
)
:
arrayReturns all identifiers from all tokens in the name pattern.
| Name | Type | Description |
|---|---|---|
| $patternString | string |
| Type | Description |
|---|---|
| array |

isTokenGroup(
string $identifier
)
:
voidChecks whether $identifier is a placeholder for a token group.
| Name | Type | Description |
|---|---|---|
| $identifier | string |

resolveNamePattern(
int $limit
=
0, string $sequence
=
''
)
:
stringReturn the real name for an object name pattern
| Name | Type | Description |
|---|---|---|
| $limit | int | The limit on the string length, by defaul 0 aka none |
| $sequence | string | End sequence applied to string if limit has been reached |
| Type | Description |
|---|---|
| string |

resolveToken(
string $token
)
:
stringLooks up the value $token should be replaced with and returns this as a string. Meta strings denothing token groups are automatically inferred.
| Name | Type | Description |
|---|---|---|
| $token | string |
| Type | Description |
|---|---|
| string |

tokenParts(
string $token
)
:
arrayReturn the different constituents of $token in an array.
The normal case here is that the different identifiers within one token will be tokenized and returned.
Example:
"<title|text>" ==> array( 'title', 'text' )
| Name | Type | Description |
|---|---|---|
| $token | string |
| Type | Description |
|---|---|
| array |