mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-12 20:21:19 +08:00
Improved yii\helpers\Inflector::slug to support more cases for Russian, Hebrew and special characters
This commit is contained in:
@@ -87,6 +87,7 @@ Yii Framework 2 Change Log
|
||||
- Enh: Added support for using path alias with `FileDependency::fileName` (qiangxue)
|
||||
- Enh: Added param `hideOnSinglePage` to `yii\widgets\LinkPager` (arturf)
|
||||
- Enh: Added support for array attributes in `in` validator (creocoder)
|
||||
- Enh: Improved `yii\helpers\Inflector::slug` to support more cases for Russian, Hebrew and special characters (samdark)
|
||||
- Chg #2898: `yii\console\controllers\AssetController` is now using hashes instead of timestamps (samdark)
|
||||
- Chg #2913: RBAC `DbManager` is now initialized via migration (samdark)
|
||||
- Chg #3036: Upgraded Twitter Bootstrap to 3.1.x (qiangxue)
|
||||
|
||||
@@ -467,9 +467,9 @@ class BaseInflector
|
||||
public static function slug($string, $replacement = '-', $lowercase = true)
|
||||
{
|
||||
if (extension_loaded('intl') === true) {
|
||||
$options = 'Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove;';
|
||||
$options = 'Any-Latin; NFKD; [:Punctuation:] Remove; [^\u0000-\u007E] Remove';
|
||||
$string = transliterator_transliterate($options, $string);
|
||||
$string = preg_replace('/[-\s]+/', $replacement, $string);
|
||||
$string = preg_replace('/[=-\s]+/', $replacement, $string);
|
||||
} else {
|
||||
$string = str_replace(array_keys(static::$transliteration), static::$transliteration, $string);
|
||||
$string = preg_replace('/[^\p{L}\p{Nd}]+/u', $replacement, $string);
|
||||
|
||||
Reference in New Issue
Block a user