48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace backend\modules\schema;
|
||
|
|
||
|
use Yii;
|
||
|
use yii\web\Application;
|
||
|
use yii\i18n\PhpMessageSource;
|
||
|
use yii\base\BootstrapInterface;
|
||
|
|
||
|
class Module extends yii\base\Module implements BootstrapInterface
|
||
|
{
|
||
|
public $controllerNamespace = 'backend\modules\schema\controllers';
|
||
|
|
||
|
public function init()
|
||
|
{
|
||
|
parent::init();
|
||
|
$this->registerTranslations();
|
||
|
}
|
||
|
|
||
|
public function registerTranslations()
|
||
|
{
|
||
|
Yii::$app->i18n->translations['schema*'] = [
|
||
|
'class' => PhpMessageSource::class,
|
||
|
'sourceLanguage' => 'ru-RU',
|
||
|
'basePath' => '@backend/modules/schema/messages',
|
||
|
'fileMap' => [
|
||
|
'schema' => 'schema.php',
|
||
|
],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public static function t($category, $message, $params = [], $language = null): string
|
||
|
{
|
||
|
return Yii::t('schema' . $category, $message, $params, $language);
|
||
|
}
|
||
|
|
||
|
public function bootstrap($app)
|
||
|
{
|
||
|
if ($app instanceof Application) {
|
||
|
$app->getUrlManager()->addRules([
|
||
|
['class' => 'yii\web\UrlRule', 'pattern' => $this->id, 'route' => $this->id . '/default/index'],
|
||
|
['class' => 'yii\web\UrlRule', 'pattern' => $this->id . '<id:\w+>', 'route' => $this->id . '/default/view'],
|
||
|
['class' => 'yii\web\UrlRule', 'pattern' => $this->id . 'default/<action:[\w\-]+>', 'route' => $this->id . '/<controller>/<action>'],
|
||
|
], false);
|
||
|
}
|
||
|
}
|
||
|
}
|