kernel/classes/eznamepatternresolver.php
File containing the eZNamePatternResolver class
- Copyright
- Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
- License
- eZ Business Use License Agreement Version 2.0
- Package
- kernel
- Version
- 4.6.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.6.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
)
:
void
Constructs 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
)
:
array
Extract all tokens from $namePattern
Example:
Text <token> more text ==> <token>
Name | Type | Description |
---|---|---|
$namePattern | string |
Type | Description |
---|---|
array |


fetchContentAttributes(
)
:
void
Fetches 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
)
:
string
Builds 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
)
:
array
Returns all identifiers from all tokens in the name pattern.
Name | Type | Description |
---|---|---|
$patternString | string |
Type | Description |
---|---|
array |


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


resolveNamePattern(
int $limit
=
0, string $sequence
=
''
)
:
string
Return 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
)
:
string
Looks 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
)
:
array
Return 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 |