Egorka
6 years ago
26 changed files with 1337 additions and 1029 deletions
@ -0,0 +1,47 @@
|
||||
<?php |
||||
/** |
||||
* Yii bootstrap file. |
||||
* Used for enhanced IDE code autocompletion. |
||||
*/ |
||||
class Yii extends \yii\BaseYii |
||||
{ |
||||
/** |
||||
* @var BaseApplication|WebApplication|ConsoleApplication the application instance |
||||
*/ |
||||
public static $app; |
||||
} |
||||
|
||||
/** |
||||
* Class BaseApplication |
||||
* Used for properties that are identical for both WebApplication and ConsoleApplication |
||||
* |
||||
* @ property \app\components\RbacManager $authManager The auth manager for this application. Null is returned if auth manager is not configured. This property is read-only. Extended component. |
||||
* @ property \app\components\Mailer $mailer The mailer component. This property is read-only. Extended component. |
||||
*/ |
||||
abstract class BaseApplication extends yii\base\Application |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* Class WebApplication |
||||
* Include only Web application related components here |
||||
* |
||||
* @property \core\components\modules\ModuleManager $moduleManager Module manager |
||||
* |
||||
* @property \core\entities\user\User $user The user component. This property is read-only. Extended component. |
||||
* @ property \app\components\MyResponse $response The response component. This property is read-only. Extended component. |
||||
* @ property \app\components\ErrorHandler $errorHandler The error handler application component. This property is read-only. Extended component. |
||||
*/ |
||||
class WebApplication extends yii\web\Application |
||||
{ |
||||
} |
||||
|
||||
/** |
||||
* Class ConsoleApplication |
||||
* Include only Console application related components here |
||||
* |
||||
* @ property \app\components\ConsoleUser $user The user component. This property is read-only. Extended component. |
||||
*/ |
||||
class ConsoleApplication extends yii\console\Application |
||||
{ |
||||
} |
@ -0,0 +1,43 @@
|
||||
<?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; |
||||
} |
||||
|
||||
/** |
||||
* 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); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
<?php |
||||
/** |
||||
* Created by Error202 |
||||
* Date: 04.09.2018 |
||||
*/ |
||||
|
||||
namespace console\controllers; |
||||
|
||||
use core\services\PermissionManager; |
||||
use yii\console\Controller; |
||||
|
||||
/** |
||||
* Permissions management from console |
||||
* Class PermissionController |
||||
* @package console\controllers |
||||
*/ |
||||
class PermissionController extends Controller |
||||
{ |
||||
/** |
||||
* @var PermissionManager Permissions management service |
||||
*/ |
||||
private $_service; |
||||
|
||||
public function __construct(string $id, $module, PermissionManager $service, array $config = []) |
||||
{ |
||||
parent::__construct($id, $module, $config); |
||||
$this->_service = $service; |
||||
} |
||||
|
||||
/** |
||||
* Create permission |
||||
* @param $name |
||||
* @param null $description |
||||
*/ |
||||
public function actionAdd($name, $description = null) : void |
||||
{ |
||||
$this->_service->create($name, $description); |
||||
} |
||||
} |
Loading…
Reference in new issue