You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.1 KiB

<?php
/**
* Created by Error202
* Date: 04.09.2018
*/
namespace console\controllers;
use core\entities\ModuleRecord;
use core\services\ModuleService;
use yii\console\Controller;
/**
* Modules management from console
* Class ModuleController
* @package console\controllers
*/
class ModuleController extends Controller
{
/**
* @var ModuleService Modules management service
*/
private $_service;
public function __construct(string $id, $module, ModuleService $service, array $config = [])
{
parent::__construct($id, $module, $config);
$this->_service = $service;
}
/**
* First modules initialization
*/
public function actionInit() : void
{
\Yii::$app->moduleManager->getModules();
}
/**
* Activate module and apply it migration if needed
* @param $name
*/
public function actionActivate($name)
{
$module = ModuleRecord::find()->andWhere(['name' => $name])->one();
if ($module || $module->isDisabled()) {
$this->_service->enable($module);
}
}
}