3
0
Fork 0
yii-cron/Module.php

50 lines
1.5 KiB
PHP
Raw Normal View History

2019-12-23 16:28:30 +03:00
<?php
namespace dominion\cron;
use yii\base\BootstrapInterface;
use yii\i18n\PhpMessageSource;
2019-12-23 16:28:30 +03:00
/**
* cron module definition class
*/
class Module extends \yii\base\Module implements BootstrapInterface
2019-12-23 16:28:30 +03:00
{
public $admins = [];
public $project = 'yii';
2019-12-23 16:28:30 +03:00
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'dominion\cron\controllers';
2019-12-23 16:28:30 +03:00
2019-12-24 13:54:32 +03:00
public function bootstrap($app)
{
if ($app instanceof \yii\web\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 . '/<controller:[\w\-]+>/<action:[\w\-]+>', 'route' => $this->id . '/<controller>/<action>'],
], false);
}
elseif ($app instanceof \yii\console\Application)
{
2019-12-24 13:54:32 +03:00
$app->controllerMap[$this->id] = [
'class' => 'dominion\cron\console\MoleController',
// 'module' => $this,
];
}
if (!isset($app->get('i18n')->translations['mole*']))
{
$app->get('i18n')->translations['mole*'] = [
'class' => PhpMessageSource::className(),
'basePath' => __DIR__ . '/messages',
'sourceLanguage' => 'en-US'
2019-12-24 13:54:32 +03:00
];
}
}
2019-12-23 16:28:30 +03:00
}