PHP Class eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter

Show file Open project: ezsystems/ezpublish-kernel Class Usage Examples

Protected Properties

Property Type Description
$configuration
$transformationProcessor eZ\Publish\Core\Persistence\TransformationProcessor Transformation processor to normalize URL strings.

Public Methods

Method Description
__construct ( TransformationProcessor $transformationProcessor, array $configuration = [] ) Creates a new URL slug converter.
convert ( string $text, string $defaultText = '_1', string | null $transformation = null ) : string Converts given $text into a URL slug consisting of URL valid characters.
getUniqueCounterValue ( string $text, boolean $isRootLevel = true ) : integer Returns unique counter number that is appended to the path element in order to make it unique against system reserved names and other entries on the same level.

Protected Methods

Method Description
cleanupText ( string $text, string $method ) : string Cleans up $text using given $method.
getWordSeparator ( ) : string Returns word separator value.

Method Details

__construct() public method

Creates a new URL slug converter.
public __construct ( TransformationProcessor $transformationProcessor, array $configuration = [] )
$transformationProcessor eZ\Publish\Core\Persistence\TransformationProcessor
$configuration array

cleanupText() protected method

Cleans up $text using given $method.
protected cleanupText ( string $text, string $method ) : string
$text string
$method string
return string

convert() public method

For non-Unicode setups this means character in the range a-z, numbers and _, for Unicode setups it means all characters except space, &, ;, /, :, =, ?, [, ], (, ), -. Invalid characters are converted to -. Example with a non-Unicode setup 'My car' => 'My-car' 'What is this?' => 'What-is-this' 'This & that' => 'This-that' 'myfile.tpl' => 'Myfile-tpl', 'øæå' => 'oeaeaa'
public convert ( string $text, string $defaultText = '_1', string | null $transformation = null ) : string
$text string
$defaultText string
$transformation string | null
return string

getUniqueCounterValue() public method

Comparison is done only if given $isRootLevel equals to true (it does by default), meaning that entry is at first level of URL. In a case when reserved name is matched method will return 2. When given $isRootLevel equals to false or when there is no match with reserved names this will return 1, which is default value not appended to name. Note: this is used only when publishing URL aliases, when creating global and custom aliases user is allowed to create first level entries that collide with reserved names. Also, in actual creation of the alias name will be further checked against existing elements under the same parent, using unique counter value determined here as starting unique counter value.
public getUniqueCounterValue ( string $text, boolean $isRootLevel = true ) : integer
$text string
$isRootLevel boolean
return integer

getWordSeparator() protected method

Returns word separator value.
protected getWordSeparator ( ) : string
return string

Property Details

$configuration protected property

protected $configuration

$transformationProcessor protected property

Transformation processor to normalize URL strings.
protected TransformationProcessor,eZ\Publish\Core\Persistence $transformationProcessor
return eZ\Publish\Core\Persistence\TransformationProcessor