/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { $app->i18n->translations['extensions-manager'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages']; DeferredQueueEvent::on(DeferredController::className(), DeferredController::EVENT_DEFERRED_QUEUE_COMPLETE, [DeferredQueueCompleteHandler::className(), 'handleEvent']); if ($app instanceof \yii\console\Application) { $app->controllerMap['extension'] = ExtensionController::className(); $app->on(Application::EVENT_BEFORE_ACTION, function () { $module = ExtensionsManager::module(); if ($module->autoDiscoverMigrations === true) { if (isset(Yii::$app->params['yii.migrations']) === false) { Yii::$app->params['yii.migrations'] = []; } /** @var array $extensions */ $extensions = $module->getExtensions(); foreach ($extensions as $name => $ext) { if ($ext['composer_type'] === Extension::TYPE_DOTPLANT && $module->discoverDotPlantMigrations === false) { continue; } $extData = ComposerInstalledSet::get()->getInstalled($ext['composer_name']); $packageMigrations = ExtensionDataHelper::getInstalledExtraData($extData, 'migrationPath', true); $packagePath = '@vendor/' . $ext['composer_name']; foreach ($packageMigrations as $migrationPath) { Yii::$app->params['yii.migrations'][] = "{$packagePath}/{$migrationPath}"; } } } }); } }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { if ($app instanceof \yii\console\Application) { // add deferred module $app->setModule('deferred', new DeferredTasksModule('deferred', $app)); // this will automatically add deferred controller to console app $app->controllerMap['deferred'] = ['class' => DeferredController::className()]; } }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { if ($app instanceof \yii\console\Application) { // add deferred module $app->setModule('deferred', new DeferredTasksModule('deferred', $app)); // this will automatically add deferred controller to console app $app->controllerMap['deferred'] = ['class' => DeferredController::className()]; } $app->i18n->translations['deferred-tasks'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages']; DeferredQueueEvent::on(DeferredController::className(), DeferredController::EVENT_DEFERRED_QUEUE_COMPLETE, [QueueCompleteEventHandler::className(), 'handleEvent']); }
public function testRunProcesses() { $files = ['task3', 'task4', 'task5', 'task6', 'task7', 'task8', 'task9', 'task10', 'task11']; foreach ($files as $f) { if (file_exists("/tmp/{$f}")) { unlink("/tmp/{$f}"); } } $time = mktime(19, 40, 0, 5, 19, 2015); $this->_controller->actionIndex('0', $time, 1); $this->assertTrue(file_exists('/tmp/task3')); $this->assertTrue(file_exists('/tmp/task4')); $this->assertTrue(file_exists('/tmp/task5') === false); $this->assertTrue(file_exists('/tmp/task6') === false); $this->assertTrue(file_exists('/tmp/task7')); $this->assertTrue(file_exists('/tmp/task8')); $this->assertTrue(file_exists('/tmp/task9')); $this->assertTrue(file_exists('/tmp/task10')); $this->assertTrue(file_exists('/tmp/task11')); }