eZPublishCommunityProject  2013.9
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter Class Reference

URL slug converter. More...

Public Member Functions

 __construct (TransformationProcessor $transformationProcessor, array $configuration=array())
 Creates a new URL slug converter. More...
 
 convert ($text, $defaultText="_1", $transformation=null)
 Converts given $text into a URL slug consisting of URL valid characters. More...
 
 getUniqueCounterValue ($text, $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. More...
 

Protected Member Functions

 cleanupText ($text, $method)
 Cleans up $text using given $method. More...
 
 getWordSeparator ()
 Returns word separator value. More...
 

Protected Attributes

 $configuration
 
 $transformationProcessor
 

Detailed Description

URL slug converter.

Constructor & Destructor Documentation

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::__construct ( TransformationProcessor  $transformationProcessor,
array  $configuration = array() 
)

Creates a new URL slug converter.

Parameters
\eZ\Publish\Core\Persistence\TransformationProcessor$transformationProcessor
array$configuration

Member Function Documentation

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::cleanupText (   $text,
  $method 
)
protected

Cleans up $text using given $method.

Parameters
string$text
string$method
Returns
string

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter\convert().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::convert (   $text,
  $defaultText = "_1",
  $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
Returns
string
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::getUniqueCounterValue (   $text,
  $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
boolean$isRootLevel
Returns
int
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::getWordSeparator ( )
protected

Returns word separator value.

Returns
string

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter\cleanupText().

Member Data Documentation

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::$configuration
protected
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter::$transformationProcessor
protected

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