mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Remvoving dependence on String class in Inflector::slug.
This commit is contained in:
parent
d72dad581a
commit
7902f6838b
1 changed files with 3 additions and 4 deletions
|
@ -429,9 +429,8 @@ class Inflector extends Object {
|
|||
* @link http://book.cakephp.org/view/572/Class-methods
|
||||
*/
|
||||
function slug($string, $replacement = '_') {
|
||||
if (!class_exists('String')) {
|
||||
require LIBS . 'string.php';
|
||||
}
|
||||
$quotedReplacement = preg_quote($replacement, '/');
|
||||
|
||||
$map = array(
|
||||
'/à|á|å|â/' => 'a',
|
||||
'/è|é|ê|ẽ|ë/' => 'e',
|
||||
|
@ -449,7 +448,7 @@ class Inflector extends Object {
|
|||
'/ß/' => 'ss',
|
||||
'/[^\w\s]/' => ' ',
|
||||
'/\\s+/' => $replacement,
|
||||
String::insert('/^[:replacement]+|[:replacement]+$/', array('replacement' => preg_quote($replacement, '/'))) => '',
|
||||
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
|
||||
);
|
||||
return preg_replace(array_keys($map), array_values($map), $string);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue