Class

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

class SlugConverter

URL slug converter.

Methods

__construct(TransformationProcessor $transformationProcessor, array $configuration = array())

Creates a new URL slug converter.

string convert(string $text, string $defaultText = '_1', string|null $transformation = null)

Converts given $text into a URL slug consisting of URL valid characters.

int getUniqueCounterValue(string $text, bool $isRootLevel = true)

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.

Details

at line 151
public __construct(TransformationProcessor $transformationProcessor, array $configuration = array())

Creates a new URL slug converter.

Parameters

TransformationProcessor $transformationProcessor
array $configuration

at line 178
public string convert(string $text, string $defaultText = '_1', string|null $transformation = null)

Converts given $text into a URL slug consisting of URL valid characters.

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'

Parameters

string $text
string $defaultText
string|null $transformation

Return Value

string

at line 223
public int getUniqueCounterValue(string $text, bool $isRootLevel = true)

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.

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.

Parameters

string $text
bool $isRootLevel

Return Value

int