Replace core class

Hi! This is a hack because of not possibility of upgrade ICU data on the server where the app is hosted.

I need to replace yii\helpers\Inflector for backend\components\Inflector just to have most of this lines removed.

public static function transliterate($string, $transliterator = null)
{
-    if (static::hasIntl()) {
-        if ($transliterator === null) {
-            $transliterator = static::$transliterator;
-        }
-
-        return transliterator_transliterate($transliterator, $string);
-    }
-
    return strtr($string, static::$transliteration);
}

So, in backend/config/bootstrap.php I write:

Yii::$container->set('yii\helpers\Inflector', 'backend\components\Inflector');

In other cases this have solve the issue. In this one, don’t.

It’s possible? I’m making any error?

https://www.yiiframework.com/doc/guide/2.0/en/helper-overview#customizing-helper-classes

1 Like