36867 Интеграция с модерацией, реализация cron-task
This commit is contained in:
41
Module.php
41
Module.php
@@ -2,33 +2,48 @@
|
||||
|
||||
namespace dominion\cron;
|
||||
|
||||
use yii\base\BootstrapInterface;
|
||||
use yii\i18n\PhpMessageSource;
|
||||
|
||||
/**
|
||||
* cron module definition class
|
||||
*/
|
||||
class Module extends \yii\base\Module
|
||||
class Module extends \yii\base\Module implements BootstrapInterface
|
||||
{
|
||||
public $admins = [];
|
||||
public $project = 'yii';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'dominion\cron\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
public function bootstrap($app)
|
||||
{
|
||||
if ($app instanceof \yii\console\Application) {
|
||||
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)
|
||||
{
|
||||
$app->controllerMap[$this->id] = [
|
||||
'class' => 'dominion\cron\console\MoleController',
|
||||
'module' => $this,
|
||||
// 'module' => $this,
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($app->get('i18n')->translations['mole*']))
|
||||
{
|
||||
$app->get('i18n')->translations['mole*'] = [
|
||||
'class' => PhpMessageSource::className(),
|
||||
'basePath' => __DIR__ . '/messages',
|
||||
'sourceLanguage' => 'en-US'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user