-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] add Realurl replace characters xclass (#159)
* [TASK] include realurl xclass from t3kit_extension_tools * [TASK] PSR-2 code standard fixes
- Loading branch information
1 parent
72eefb1
commit 051b365
Showing
2 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
|
||
namespace T3kit\themeT3kit\Xclass\Realurl; | ||
|
||
use T3kit\themeT3kit\Utility\HelperUtility; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* Class Utility | ||
* @package T3kit\themeT3kit\Xclass\Realurl\Utility | ||
*/ | ||
class Utility extends \DmitryDulepov\Realurl\Utility | ||
{ | ||
/** | ||
* Array of replacement characters | ||
* | ||
* @var array | ||
*/ | ||
protected static $replacements = [ | ||
'ä' => 'a', | ||
'å' => 'a', | ||
'ö' => 'o', | ||
'Å' => 'a', | ||
'Ä' => 'a', | ||
'Ö' => 'o' | ||
]; | ||
|
||
/** | ||
* Xclass standard Reaurl utility to remove some specials characters | ||
* | ||
* @param string $processedTitle | ||
* @param string $spaceCharacter | ||
* @param bool $strToLower | ||
* @return string | ||
*/ | ||
public function convertToSafeString($processedTitle, $spaceCharacter = '-', $strToLower = true) | ||
{ | ||
$processedTitle = str_replace( | ||
array_keys($this->getFinalCharsReplacements()), | ||
$this->getFinalCharsReplacements(), | ||
$processedTitle | ||
); | ||
|
||
return parent::convertToSafeString($processedTitle, $spaceCharacter, $strToLower); | ||
} | ||
|
||
/** | ||
* Check in extension configuration for additional replacements | ||
* | ||
* @return array|null | ||
*/ | ||
protected function getFinalCharsReplacements() | ||
{ | ||
static $finalReplacements = null; | ||
|
||
if ($finalReplacements === null) { | ||
$t3kitExtToolConf = HelperUtility::getExtConf(); | ||
$additionalChars = []; | ||
|
||
if (!empty($t3kitExtToolConf['additionalCharacters'])) { | ||
|
||
$charsSet = GeneralUtility::trimExplode(',', $t3kitExtToolConf['additionalCharacters']); | ||
|
||
foreach ($charsSet as $charSet) { | ||
list($find, $replace) = GeneralUtility::trimExplode('=>', $charSet, true); | ||
$additionalChars[$find] = $replace; | ||
} | ||
} | ||
|
||
$finalReplacements = array_merge(self::$replacements, $additionalChars); | ||
} | ||
|
||
return $finalReplacements; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters