/**
* 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'
*
* @param string $text
* @param string $defaultText
* @param string|null $transformation
*
* @return string
*/
public function convert($text, $defaultText = '_1', $transformation = null)
{
if (!isset($transformation)) {
$transformation = $this->configuration['transformation'];
}
if (strlen($text) === 0) {
$text = $defaultText;
}
if (isset($this->configuration['transformationGroups'][$transformation]['commands']) && !empty($this->configuration['transformationGroups'][$transformation]['commands'])) {
$text = $this->transformationProcessor->transform($text, $this->configuration['transformationGroups'][$transformation]['commands']);
}
return $this->cleanupText($text, $this->configuration['transformationGroups'][$transformation]['cleanupMethod']);
}