PHP Class eZ\Publish\Core\Repository\Helper\NameSchemaService

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.
Show file Open project: ezsystems/ezpublish-kernel Class Usage Examples

Protected Properties

Property Type Description
$contentTypeDomainMapper ContentTypeDomainMapper
$contentTypeHandler eZ\Publish\SPI\Persistence\Content\Type\Handler
$nameableFieldTypeRegistry NameableFieldTypeRegistry
$settings array

Public Methods

Method Description
__construct ( eZ\Publish\SPI\Persistence\Content\Type\Handler $contentTypeHandler, ContentTypeDomainMapper $contentTypeDomainMapper, NameableFieldTypeRegistry $nameableFieldTypeRegistry, array $settings = [] ) Constructs a object to resolve $nameSchema with $contentVersion fields values.
resolve ( string $nameSchema, eZ\Publish\SPI\Persistence\Content\Type | eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType, array $fieldMap, array $languageCodes ) : string Returns the real name for a content name pattern.
resolveNameSchema ( eZ\Publish\API\Repository\Values\Content\Content $content, array $fieldMap = [], array $languageCodes = [], eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType = null ) : array Convenience method for resolving name schema.
resolveUrlAliasSchema ( eZ\Publish\API\Repository\Values\Content\Content $content, eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType = null ) : array Convenience method for resolving URL alias schema.

Protected Methods

Method Description
extractTokens ( string $nameSchema ) : array Extract all tokens from $namePattern.
filterNameSchema ( string $nameSchema ) : string Builds a lookup / translation table for groups in the $namePattern.
getFieldTitles ( array $schemaIdentifiers, eZ\Publish\SPI\Persistence\Content\Type | eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType, array $fieldMap, string $languageCode ) : string[] Fetches the list of available Field identifiers in the token and returns an array of their current title value.
getIdentifiers ( string $schemaString ) : array Returns all identifiers from all tokens in the name schema.
isTokenGroup ( string $identifier ) : boolean Checks whether $identifier is a placeholder for a token group.
mergeFieldMap ( eZ\Publish\API\Repository\Values\Content\Content $content, array $fieldMap, array $languageCodes ) : array Convenience method for resolving name schema.
resolveToken ( string $token, array $titles, array $groupLookupTable ) : string Looks up the value $token should be replaced with and returns this as a string. Meta strings denoting token groups are automatically inferred.
tokenParts ( string $token ) : array Returns the different constituents of $token in an array.

Method Details

__construct() public method

Constructs a object to resolve $nameSchema with $contentVersion fields values.
public __construct ( eZ\Publish\SPI\Persistence\Content\Type\Handler $contentTypeHandler, ContentTypeDomainMapper $contentTypeDomainMapper, NameableFieldTypeRegistry $nameableFieldTypeRegistry, array $settings = [] )
$contentTypeHandler eZ\Publish\SPI\Persistence\Content\Type\Handler
$contentTypeDomainMapper ContentTypeDomainMapper
$nameableFieldTypeRegistry NameableFieldTypeRegistry
$settings array

extractTokens() protected method

Example: Text <token> more text ==> <token>
protected extractTokens ( string $nameSchema ) : array
$nameSchema string
return array

filterNameSchema() protected method

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.
protected filterNameSchema ( string $nameSchema ) : string
$nameSchema string
return string

getFieldTitles() protected method

Fetches the list of available Field identifiers in the token and returns an array of their current title value.
See also: eZ\Publish\Core\Repository\FieldType::getName()
protected getFieldTitles ( array $schemaIdentifiers, eZ\Publish\SPI\Persistence\Content\Type | eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType, array $fieldMap, string $languageCode ) : string[]
$schemaIdentifiers array
$contentType eZ\Publish\SPI\Persistence\Content\Type | eZ\Publish\API\Repository\Values\ContentType\ContentType
$fieldMap array
$languageCode string
return string[] Key is the field identifier, value is the title value

getIdentifiers() protected method

Returns all identifiers from all tokens in the name schema.
protected getIdentifiers ( string $schemaString ) : array
$schemaString string
return array

isTokenGroup() protected method

Checks whether $identifier is a placeholder for a token group.
protected isTokenGroup ( string $identifier ) : boolean
$identifier string
return boolean

mergeFieldMap() protected method

Convenience method for resolving name schema.
protected mergeFieldMap ( eZ\Publish\API\Repository\Values\Content\Content $content, array $fieldMap, array $languageCodes ) : array
$content eZ\Publish\API\Repository\Values\Content\Content
$fieldMap array
$languageCodes array
return array

resolve() public method

Returns the real name for a content name pattern.
public resolve ( string $nameSchema, eZ\Publish\SPI\Persistence\Content\Type | eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType, array $fieldMap, array $languageCodes ) : string
$nameSchema string
$contentType eZ\Publish\SPI\Persistence\Content\Type | eZ\Publish\API\Repository\Values\ContentType\ContentType
$fieldMap array
$languageCodes array
return string

resolveNameSchema() public method

Convenience method for resolving name schema.
public resolveNameSchema ( eZ\Publish\API\Repository\Values\Content\Content $content, array $fieldMap = [], array $languageCodes = [], eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType = null ) : array
$content eZ\Publish\API\Repository\Values\Content\Content
$fieldMap array
$languageCodes array
$contentType eZ\Publish\API\Repository\Values\ContentType\ContentType
return array

resolveToken() protected method

Looks up the value $token should be replaced with and returns this as a string. Meta strings denoting token groups are automatically inferred.
protected resolveToken ( string $token, array $titles, array $groupLookupTable ) : string
$token string
$titles array
$groupLookupTable array
return string

resolveUrlAliasSchema() public method

Convenience method for resolving URL alias schema.
public resolveUrlAliasSchema ( eZ\Publish\API\Repository\Values\Content\Content $content, eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType = null ) : array
$content eZ\Publish\API\Repository\Values\Content\Content
$contentType eZ\Publish\API\Repository\Values\ContentType\ContentType
return array

tokenParts() protected method

The normal case here is that the different identifiers within one token will be tokenized and returned. Example: "<title|text>" ==> array( 'title', 'text' )
protected tokenParts ( string $token ) : array
$token string
return array

Property Details

$contentTypeDomainMapper protected property

protected ContentTypeDomainMapper,eZ\Publish\Core\Repository\Helper $contentTypeDomainMapper
return ContentTypeDomainMapper

$contentTypeHandler protected property

protected Handler,eZ\Publish\SPI\Persistence\Content\Type $contentTypeHandler
return eZ\Publish\SPI\Persistence\Content\Type\Handler

$nameableFieldTypeRegistry protected property

protected NameableFieldTypeRegistry,eZ\Publish\Core\Repository\Helper $nameableFieldTypeRegistry
return NameableFieldTypeRegistry

$settings protected property

protected array $settings
return array