eZPublishCommunityProject  2013.9
eZ\Publish\Core\Repository\NameSchemaService Class Reference

NameSchemaService is internal service for resolving content name and url alias patterns. More...

Public Member Functions

 __construct (RepositoryInterface $repository, array $settings=array())
 Constructs a object to resolve $nameSchema with $contentVersion fields values. More...
 
 resolve ($nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes)
 Returns the real name for a content name pattern. More...
 
 resolveNameSchema (Content $content, array $fieldMap=array(), array $languageCodes=array(), ContentType $contentType=null)
 Convenience method for resolving name schema. More...
 
 resolveUrlAliasSchema (Content $content, ContentType $contentType=null)
 Convenience method for resolving URL alias schema. More...
 

Public Attributes

const META_STRING = 'EZMETAGROUP_'
 

Protected Member Functions

 extractTokens ($nameSchema)
 Extract all tokens from $namePattern. More...
 
 filterNameSchema ($nameSchema)
 Builds a lookup / translation table for groups in the $namePattern. More...
 
 getFieldTitles (array $schemaIdentifiers, ContentType $contentType, array $fieldMap, $languageCode)
 Fetches the list of available Field identifiers in the token and returns an array of their current title value. More...
 
 getIdentifiers ($schemaString)
 Returns all identifiers from all tokens in the name schema. More...
 
 isTokenGroup ($identifier)
 Checks whether $identifier is a placeholder for a token group. More...
 
 mergeFieldMap (Content $content, array $fieldMap, array $languageCodes)
 Convenience method for resolving name schema. More...
 
 resolveToken ($token, $titles, $groupLookupTable)
 Looks up the value $token should be replaced with and returns this as a string. More...
 
 tokenParts ($token)
 Returns the different constituents of $token in an array. More...
 

Protected Attributes

 $repository
 
 $settings
 

Detailed Description

NameSchemaService is internal service for resolving content name and url alias patterns.

This code supports content 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 fields. So a match means that that the current field has data.

Tokens are the field definition identifiers which are used in the class edit-interface.

Constructor & Destructor Documentation

eZ\Publish\Core\Repository\NameSchemaService::__construct ( RepositoryInterface  $repository,
array  $settings = array() 
)

Constructs a object to resolve $nameSchema with $contentVersion fields values.

Parameters
\eZ\Publish\API\Repository\Repository$repository
array$settings
Returns

Member Function Documentation

eZ\Publish\Core\Repository\NameSchemaService::extractTokens (   $nameSchema)
protected

Extract all tokens from $namePattern.

Example: Text <token> more text ==> <token>

Parameters
string$nameSchema
Returns
array

Referenced by eZ\Publish\Core\Repository\NameSchemaService\resolve(), and eZ\Publish\Core\Repository\NameSchemaService\resolveToken().

eZ\Publish\Core\Repository\NameSchemaService::filterNameSchema (   $nameSchema)
protected

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.

Parameters
string$nameSchema
Returns
string

Referenced by eZ\Publish\Core\Repository\NameSchemaService\resolve().

eZ\Publish\Core\Repository\NameSchemaService::getFieldTitles ( array  $schemaIdentifiers,
ContentType  $contentType,
array  $fieldMap,
  $languageCode 
)
protected

Fetches the list of available Field identifiers in the token and returns an array of their current title value.

See Also
::getName()
Parameters
string[]$schemaIdentifiers
\eZ\Publish\API\Repository\Values\ContentType\ContentType$contentType$fieldDefinitions
array$fieldMap
string$languageCode
Returns
string[] Key is the field identifier, value is the title value

Referenced by eZ\Publish\Core\Repository\NameSchemaService\resolve().

eZ\Publish\Core\Repository\NameSchemaService::getIdentifiers (   $schemaString)
protected

Returns all identifiers from all tokens in the name schema.

Parameters
string$schemaString
Returns
array

Referenced by eZ\Publish\Core\Repository\NameSchemaService\resolve().

eZ\Publish\Core\Repository\NameSchemaService::isTokenGroup (   $identifier)
protected

Checks whether $identifier is a placeholder for a token group.

Parameters
string$identifier
Returns
boolean

Referenced by eZ\Publish\Core\Repository\NameSchemaService\resolveToken().

eZ\Publish\Core\Repository\NameSchemaService::mergeFieldMap ( Content  $content,
array  $fieldMap,
array  $languageCodes 
)
protected

Convenience method for resolving name schema.

Parameters
\eZ\Publish\API\Repository\Values\Content\Content$content
array$fieldMap
array$languageCodes
Returns
array
eZ\Publish\Core\Repository\NameSchemaService::resolve (   $nameSchema,
ContentType  $contentType,
array  $fieldMap,
array  $languageCodes 
)

Returns the real name for a content name pattern.

Parameters
string$nameSchema
\eZ\Publish\API\Repository\Values\ContentType\ContentType$contentType
array$fieldMap
array$languageCodes
Returns
string

Referenced by eZ\Publish\Core\Repository\NameSchemaService\resolveNameSchema(), and eZ\Publish\Core\Repository\NameSchemaService\resolveUrlAliasSchema().

eZ\Publish\Core\Repository\NameSchemaService::resolveNameSchema ( Content  $content,
array  $fieldMap = array(),
array  $languageCodes = array(),
ContentType  $contentType = null 
)

Convenience method for resolving name schema.

Parameters
\eZ\Publish\API\Repository\Values\Content\Content$content
array$fieldMap
array$languageCodes
\eZ\Publish\API\Repository\Values\ContentType\ContentType | null$contentType
Returns
array
eZ\Publish\Core\Repository\NameSchemaService::resolveToken (   $token,
  $titles,
  $groupLookupTable 
)
protected

Looks up the value $token should be replaced with and returns this as a string.

Meta strings denoting token groups are automatically inferred.

Parameters
string$token
array$titles
array$groupLookupTable
Returns
string

Referenced by eZ\Publish\Core\Repository\NameSchemaService\resolve().

eZ\Publish\Core\Repository\NameSchemaService::resolveUrlAliasSchema ( Content  $content,
ContentType  $contentType = null 
)

Convenience method for resolving URL alias schema.

Parameters
\eZ\Publish\API\Repository\Values\Content\Content$content
\eZ\Publish\API\Repository\Values\ContentType\ContentType | null$contentType
Returns
array
eZ\Publish\Core\Repository\NameSchemaService::tokenParts (   $token)
protected

Returns 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: "&lt;title|text&gt;" ==> array( 'title', 'text' )

Parameters
string$token
Returns
array

Referenced by eZ\Publish\Core\Repository\NameSchemaService\resolveToken().

Member Data Documentation

eZ\Publish\Core\Repository\NameSchemaService::$repository
protected
eZ\Publish\Core\Repository\NameSchemaService::$settings
protected
const eZ\Publish\Core\Repository\NameSchemaService::META_STRING = 'EZMETAGROUP_'

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