Browse Source

Code format

Installer fix
IDE Yii autocompletion
master
Egorka 6 years ago
parent
commit
8dd38b6e00
  1. 47
      Yii.php
  2. 8
      backend/controllers/AuthController.php
  3. 78
      backend/controllers/MenuController.php
  4. 20
      backend/controllers/ModuleController.php
  5. 29
      backend/controllers/PermissionController.php
  6. 48
      backend/controllers/RoleController.php
  7. 18
      backend/controllers/SiteController.php
  8. 16
      backend/controllers/SliderController.php
  9. 28
      backend/controllers/UserController.php
  10. 27
      backend/controllers/settings/ListController.php
  11. 27
      backend/views/role/view.php
  12. 43
      console/controllers/ModuleController.php
  13. 39
      console/controllers/PermissionController.php
  14. 8
      console/controllers/UserController.php
  15. 9
      core/entities/Settings.php
  16. 15
      core/services/SettingsService.php
  17. 1
      core/services/user/UserManageService.php
  18. 2
      frontend/config/main.php
  19. 9
      frontend/controllers/ContactController.php
  20. 21
      frontend/controllers/SiteController.php
  21. 11
      frontend/controllers/account/ProfileController.php
  22. 8
      frontend/controllers/auth/AuthController.php
  23. 6
      frontend/controllers/auth/NetworkController.php
  24. 10
      frontend/controllers/auth/ResetController.php
  25. 15
      frontend/controllers/auth/SignupController.php
  26. 167
      setup.php

47
Yii.php

@ -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
{
}

8
backend/controllers/AuthController.php

@ -1,4 +1,5 @@
<?php
namespace backend\controllers;
use common\auth\Identity;
@ -11,12 +12,12 @@ use yii\filters\AccessControl;
class AuthController extends Controller
{
private $authService;
private $_auth_service;
public function __construct($id, $module, AuthService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->authService = $service;
$this->_auth_service = $service;
}
/**
@ -67,8 +68,9 @@ class AuthController extends Controller
$form = new LoginForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$user = $this->authService->auth($form);
$user = $this->_auth_service->auth($form);
Yii::$app->user->login(new Identity($user), $form->rememberMe ? 3600 * 24 * 30 : 0);
return $this->goBack();
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);

78
backend/controllers/MenuController.php

@ -26,8 +26,14 @@ class MenuController extends Controller
public $menu_service;
public $menu_item_service;
public function __construct( string $id, $module, MenuManageService $menu_service, MenuItemManageService $menu_item_service, array $config = [] ) {
parent::__construct( $id, $module, $config );
public function __construct(
string $id,
$module,
MenuManageService $menu_service,
MenuItemManageService $menu_item_service,
array $config = []
) {
parent::__construct($id, $module, $config);
$this->menu_service = $menu_service;
$this->menu_item_service = $menu_item_service;
@ -70,8 +76,7 @@ class MenuController extends Controller
$form = new MenuSelectForm();
if ($form->load(Yii::$app->request->get()) && $form->validate()) {
return $this->redirect(['menu/index', 'id' => $form->id]);
}
elseif ($id) {
} elseif ($id) {
$this->createMenuItem(); // create menu item if MenuItemForm sent
$menu = $this->findModel($id);
@ -84,8 +89,7 @@ class MenuController extends Controller
'menu' => $menu,
'creator' => $creatorWidgets,
]);
}
else {
} else {
return $this->render('select_menu', [
'model' => $form,
'menus' => $menus,
@ -99,12 +103,14 @@ class MenuController extends Controller
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$menu = $this->menu_service->create($form);
return $this->redirect(['index', 'id' => $menu->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
@ -118,12 +124,14 @@ class MenuController extends Controller
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->menu_service->edit($menu->id, $form);
return $this->redirect(['index', 'id' => $menu->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
'menu' => $menu,
@ -138,6 +146,7 @@ class MenuController extends Controller
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['index']);
}
@ -148,12 +157,14 @@ class MenuController extends Controller
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->menu_item_service->edit($item->id, $form);
return $this->redirect(['index', 'id' => $item->menu_id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->redirect(['index', 'id' => $item->menu_id]);
}
@ -164,55 +175,18 @@ class MenuController extends Controller
try {
$id = Yii::$app->request->post('id');
$item = $this->findItemModel($id);
//$this->deleteItem($item);
$item->delete();
Yii::$app->session->setFlash('success', Yii::t('menu', 'Menu Item Deleted'));
return [ 'result' => 'success' ];
return ['result' => 'success'];
} catch (\RuntimeException $e) {
return ['result' => 'error', 'message' => $e->getMessage()];
}
catch (\RuntimeException $e) {
return [ 'result' => 'error', 'message' => $e->getMessage() ];
}
}
return ['result' => 'error', 'message' => 'Request error'];
}
/*
public function actionSaveMenuItemData()
{
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
if (Yii::$app->request->isAjax) {
try {
$id = Yii::$app->request->post('id');
$name = Yii::$app->request->post('name');
$title = Yii::$app->request->post('title');
$style = Yii::$app->request->post('style');
$css = Yii::$app->request->post('css');
$url = Yii::$app->request->post('url');
$target = Yii::$app->request->post('target');
$item = $this->findItemModel($id);
$item->name = $name;
$item->title_attr = $title;
$item->style = $style;
$item->css = $css;
$item->url = $url;
$item->target = $target;
$item->save();
Yii::$app->session->setFlash('success', Yii::t('menu', 'Menu Item Saved'));
return [ 'result' => 'success' ];
}
catch (\RuntimeException $e) {
return [ 'result' => 'error', 'message' => $e->getMessage() ];
}
}
return ['result' => 'error', 'message' => 'Request error'];
}
*/
public function actionSaveMenuItems()
{
@ -223,16 +197,17 @@ class MenuController extends Controller
$order = [];
$items = Json::decode($json, true);
foreach ($items as $item) {
$order[$item[1]] = isset($order[$item[1]]) ? $order[$item[1]]+1 : 0;
$order[$item[1]] = isset($order[$item[1]]) ? $order[$item[1]] + 1 : 0;
$this->menu_item_service->setPosition($item, $order[$item[1]]);
}
Yii::$app->session->setFlash('success', Yii::t('menu', 'Menu Saved'));
return [ 'result' => 'success' ];
}
catch (\RuntimeException $e) {
return [ 'result' => 'error', 'message' => $e->getMessage() ];
return ['result' => 'success'];
} catch (\RuntimeException $e) {
return ['result' => 'error', 'message' => $e->getMessage()];
}
}
return ['result' => 'error', 'message' => 'Request error'];
}
@ -246,6 +221,7 @@ class MenuController extends Controller
$widgets = is_array($module_widgets) ? array_merge($widgets, $module_widgets) : $widgets;
}
}
return $widgets;
}

20
backend/controllers/ModuleController.php

@ -6,7 +6,6 @@
namespace backend\controllers;
use core\entities\ModuleRecord;
use core\services\ModuleService;
use yii\web\Controller;
@ -16,11 +15,12 @@ use yii\web\NotFoundHttpException;
class ModuleController extends Controller
{
private $service;
private $_service;
public function __construct( string $id, $module, ModuleService $service, array $config = [] ) {
parent::__construct( $id, $module, $config );
$this->service = $service;
public function __construct(string $id, $module, ModuleService $service, array $config = [])
{
parent::__construct($id, $module, $config);
$this->_service = $service;
}
public function behaviors(): array
@ -53,7 +53,6 @@ class ModuleController extends Controller
public function actionList()
{
//$modules = ModuleRecord::find()->all();
$modules = \Yii::$app->moduleManager->getModules();
return $this->render('list', [
@ -64,21 +63,24 @@ class ModuleController extends Controller
public function actionDelete($id)
{
$module = $this->findModel($id);
$this->service->delete($module);
$this->_service->delete($module);
return $this->redirect(['module/list']);
}
public function actionDisable($id)
{
$module = $this->findModel($id);
$this->service->disable($module);
$this->_service->disable($module);
return $this->redirect(['module/list']);
}
public function actionEnable($id)
{
$module = $this->findModel($id);
$this->service->enable($module);
$this->_service->enable($module);
return $this->redirect(['module/list']);
}

29
backend/controllers/PermissionController.php

@ -19,12 +19,12 @@ use yii\filters\AccessControl;
class PermissionController extends Controller
{
private $permission;
private $_permission;
public function __construct($id, $module, PermissionManager $permission, $config = [])
{
parent::__construct($id, $module, $config);
$this->permission = $permission;
$this->_permission = $permission;
}
/**
@ -34,13 +34,13 @@ class PermissionController extends Controller
{
return [
[
'class' => TimestampBehavior::className(),
'class' => TimestampBehavior::class,
],
'access' => [
'class' => AccessControl::className(),
'class' => AccessControl::class,
'rules' => [
[
'actions' => ['create','view','index', 'update', 'delete'],
'actions' => ['create', 'view', 'index', 'update', 'delete'],
'allow' => true,
'roles' => ['UserManagement'],
],
@ -51,7 +51,7 @@ class PermissionController extends Controller
],
],
'verbs' => [
'class' => VerbFilter::className(),
'class' => VerbFilter::class,
'actions' => [
'delete' => ['POST'],
],
@ -61,12 +61,12 @@ class PermissionController extends Controller
public function actionIndex()
{
$data = array_map(function (Permission $permission){
$data = array_map(function (Permission $permission) {
return [
'name' => $permission->name,
'description' => $permission->description,
];
}, $this->permission->getPermissions());
}, $this->_permission->getPermissions());
$dataProvider = new ArrayDataProvider([
'allModels' => $data,
@ -86,13 +86,15 @@ class PermissionController extends Controller
$form = new RbacCreatePermissionForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->permission->create($form->name, $form->description, $form->rule_name, $form->data);
$this->_permission->create($form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
@ -105,13 +107,15 @@ class PermissionController extends Controller
$form = new RbacEditPermissionForm($permission);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->permission->update($permission->name, $form->name, $form->description, $form->rule_name, $form->data);
$this->_permission->update($permission->name, $form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
]);
@ -119,7 +123,8 @@ class PermissionController extends Controller
public function actionDelete($id)
{
$this->permission->delete($id);
$this->_permission->delete($id);
return $this->redirect(['index']);
}
@ -132,6 +137,6 @@ class PermissionController extends Controller
protected function findModel($id)
{
return $this->permission->getPermission($id);
return $this->_permission->getPermission($id);
}
}

48
backend/controllers/RoleController.php

@ -20,14 +20,14 @@ use Yii;
class RoleController extends Controller
{
private $role;
private $permission;
private $_role;
private $_permission;
public function __construct($id, $module, RoleManager $role, PermissionManager $permission, $config = [])
{
parent::__construct($id, $module, $config);
$this->role = $role;
$this->permission = $permission;
$this->_role = $role;
$this->_permission = $permission;
}
/**
@ -37,13 +37,13 @@ class RoleController extends Controller
{
return [
[
'class' => TimestampBehavior::className(),
'class' => TimestampBehavior::class,
],
'access' => [
'class' => AccessControl::className(),
'class' => AccessControl::class,
'rules' => [
[
'actions' => ['create','view','index', 'update', 'delete'],
'actions' => ['create', 'view', 'index', 'update', 'delete'],
'allow' => true,
'roles' => ['UserManagement'],
],
@ -54,7 +54,7 @@ class RoleController extends Controller
],
],
'verbs' => [
'class' => VerbFilter::className(),
'class' => VerbFilter::class,
'actions' => [
'delete' => ['POST'],
],
@ -64,7 +64,7 @@ class RoleController extends Controller
public function actionIndex()
{
$data = $this->role->getRolesListArray();
$data = $this->_role->getRolesListArray();
$dataProvider = new ArrayDataProvider([
'allModels' => $data,
@ -84,13 +84,15 @@ class RoleController extends Controller
$form = new RbacCreateRoleForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->role->create($form->name, $form->description, $form->rule_name, $form->data);
$this->_role->create($form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
@ -103,13 +105,15 @@ class RoleController extends Controller
$form = new RbacEditRoleForm($role);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->role->update($role->name, $form->name, $form->description, $form->rule_name, $form->data);
$this->_role->update($role->name, $form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
]);
@ -118,31 +122,30 @@ class RoleController extends Controller
public function actionDelete($id)
{
try {
$this->role->delete($id);
}
catch (\DomainException $e)
{
$this->_role->delete($id);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['index']);
}
public function actionView($id)
{
$currentRole = $this->role->getRole($id);
$rolesSelectArray = array_diff_assoc($this->role->getRolesSelectArray(), [$currentRole->name => $currentRole->description]);
$currentRole = $this->_role->getRole($id);
$rolesSelectArray = array_diff_assoc($this->_role->getRolesSelectArray(), [$currentRole->name => $currentRole->description]);
$itemsForm = new RbacUpdateChildren();
if ($itemsForm->load(Yii::$app->request->post()) && $itemsForm->validate()) {
$this->role->saveChildren($id, $itemsForm->roles, $itemsForm->permissions);
$this->_role->saveChildren($id, $itemsForm->roles, $itemsForm->permissions);
Yii::$app->session->setFlash('success', Yii::t('user', 'Children roles and permissions for "{role}" is updated.', ['role' => $currentRole->description]));
}
$rolesSelected = $this->role->getRolesSelectArrayByRole($id);
$rolesSelected = $this->_role->getRolesSelectArrayByRole($id);
$permissionsSelectArray = $this->permission->getPermissionsSelectArray();
$permissionsSelected = $this->permission->getPermissionsSelectArrayByRole($id);
$permissionsSelectArray = $this->_permission->getPermissionsSelectArray();
$permissionsSelected = $this->_permission->getPermissionsSelectArrayByRole($id);
$itemsForm->roles = $rolesSelected;
$itemsForm->permissions = $permissionsSelected;
@ -151,13 +154,12 @@ class RoleController extends Controller
'model' => $this->findModel($id),
'roles' => $rolesSelectArray,
'permissions' => $permissionsSelectArray,
'permissionsSelected' => $permissionsSelected,
'itemsForm' => $itemsForm,
]);
}
protected function findModel($id)
{
return $this->role->getRole($id);
return $this->_role->getRole($id);
}
}

18
backend/controllers/SiteController.php

@ -1,28 +1,27 @@
<?php
namespace backend\controllers;
use core\entities\Search;
use core\forms\SearchForm;
use core\helpers\LanguageHelper;
use core\services\user\UserManageService;
use Yii;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use yii\web\NotFoundHttpException;
/**
* Site controller
*/
class SiteController extends Controller
{
private $service;
private $_service;
public function __construct( string $id, $module, UserManageService $service, array $config = [] ) {
parent::__construct( $id, $module, $config );
$this->service = $service;
public function __construct(string $id, $module, UserManageService $service, array $config = [])
{
parent::__construct($id, $module, $config);
$this->_service = $service;
}
/**
@ -111,14 +110,16 @@ class SiteController extends Controller
//Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return '';
}
public function actionLanguage($language)
{
if ($language && in_array($language, array_keys(Yii::$app->params['backendTranslatedLanguages']))) {
$this->service->setBackendLanguage($language);
$this->_service->setBackendLanguage($language);
}
return $this->redirect(Yii::$app->request->referrer);
}
@ -127,6 +128,7 @@ class SiteController extends Controller
if ($action->id === 'error') {
$this->layout = 'error';
}
return parent::beforeAction($action);
}
}

16
backend/controllers/SliderController.php

@ -12,15 +12,14 @@ use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
class SliderController extends Controller
{
private $service;
private $_service;
public function __construct($id, $module, SliderService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
$this->_service = $service;
}
/**
@ -98,13 +97,15 @@ class SliderController extends Controller
$form->scenario = Slider::SCENARIO_CREATE;
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$slider = $this->service->create($form);
$slider = $this->_service->create($form);
return $this->redirect(['view', 'id' => $slider->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
@ -124,13 +125,15 @@ class SliderController extends Controller
$form->scenario = Slider::SCENARIO_UPDATE;
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($slider->id, $form);
$this->_service->edit($slider->id, $form);
return $this->redirect(['view', 'id' => $slider->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
'slider' => $slider,
@ -144,7 +147,8 @@ class SliderController extends Controller
*/
public function actionDelete($id)
{
$this->service->remove($id);
$this->_service->remove($id);
return $this->redirect(['index']);
}

28
backend/controllers/UserController.php

@ -20,14 +20,14 @@ use yii\web\UploadedFile;
*/
class UserController extends Controller
{
private $service;
private $profile_service;
private $_service;
private $_profile_service;
public function __construct($id, $module, UserManageService $service, ProfileService $profile_service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
$this->profile_service = $profile_service;
$this->_service = $service;
$this->_profile_service = $profile_service;
}
/**
@ -40,7 +40,7 @@ class UserController extends Controller
'class' => AccessControl::class,
'rules' => [
[
'actions' => ['create','view','index', 'update', 'delete'],
'actions' => ['create', 'view', 'index', 'update', 'delete'],
'allow' => true,
'roles' => ['UserManagement'],
],
@ -102,13 +102,15 @@ class UserController extends Controller
$form = new UserForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$user = $this->service->create($form);
$user = $this->_service->create($form);
return $this->redirect(['view', 'id' => $user->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
@ -127,13 +129,15 @@ class UserController extends Controller
$form = new UserForm($user);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($user->id, $form);
$this->_service->edit($user->id, $form);
return $this->redirect(['view', 'id' => $user->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
'user' => $user,
@ -143,12 +147,15 @@ class UserController extends Controller
/**
* Deletes an existing User model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
* @param integer $id
*
* @return mixed
*/
public function actionDelete($id)
{
$this->service->remove($id);
$this->_service->remove($id);
return $this->redirect(['index']);
}
@ -160,8 +167,9 @@ class UserController extends Controller
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$form->user_pic = UploadedFile::getInstance($form, 'user_pic');
$this->profile_service->edit(Yii::$app->user->id, $form);
$this->_profile_service->edit(Yii::$app->user->id, $form);
Yii::$app->session->setFlash('success', Yii::t('user', 'Profile is saved.'));
return $this->redirect(['/user/profile']);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
@ -178,7 +186,9 @@ class UserController extends Controller
/**
* Finds the User model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @param integer $id
*
* @return User the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/

27
backend/controllers/settings/ListController.php

@ -6,7 +6,6 @@
namespace backend\controllers\settings;
use backend\forms\SettingsSearch;
use core\entities\Settings;
use core\forms\SettingsForm;
@ -20,11 +19,12 @@ use yii\web\NotFoundHttpException;
class ListController extends Controller
{
private $service;
private $_service;
public function __construct( string $id, $module, SettingsService $service, array $config = [] ) {
parent::__construct( $id, $module, $config );
$this->service = $service;
public function __construct(string $id, $module, SettingsService $service, array $config = [])
{
parent::__construct($id, $module, $config);
$this->_service = $service;
}
public function behaviors()
@ -40,7 +40,7 @@ class ListController extends Controller
'class' => AccessControl::class,
'rules' => [
[
'actions' => ['create','view','index', 'update', 'delete', 'toggle'],
'actions' => ['create', 'view', 'index', 'update', 'delete', 'toggle'],
'allow' => true,
'roles' => ['SettingsManagement'],
],
@ -68,6 +68,7 @@ class ListController extends Controller
{
$searchModel = new SettingsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render(
'index',
[
@ -92,16 +93,17 @@ class ListController extends Controller
$form = new SettingsForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$settings = $this->service->create($form);
$settings = $this->_service->create($form);
return $this->redirect(['view', 'id' => $settings->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
else {
} else {
$form->active = 1;
}
return $this->render(
'create',
[
@ -117,13 +119,15 @@ class ListController extends Controller
$form = new SettingsForm($settings);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($settings->id, $form);
$this->_service->edit($settings->id, $form);
return $this->redirect(['view', 'id' => $settings->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render(
'update',
[
@ -135,7 +139,8 @@ class ListController extends Controller
public function actionDelete($id)
{
$this->service->remove($id);
$this->_service->remove($id);
return $this->redirect(['index']);
}

27
backend/views/role/view.php

@ -1,4 +1,5 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use kartik\select2\Select2;
@ -53,35 +54,45 @@ $this->params['breadcrumbs'][] = $this->title;
</div>
<?php if ($model->name !== 'admin'): ?>
<?php if ($model->name !== 'admin') : ?>
<h4><?= Yii::t('user', 'Contains roles') ?></h4>
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($itemsForm, 'roles')->widget(
Select2::classname(), [
Select2::class,
[
'name' => 'childrenRoles',
'data' => $roles,
'size' => Select2::SMALL,
'options' => ['placeholder' => Yii::t('user', 'Select role...'), 'multiple' => true],
'options' => [
'placeholder' => Yii::t('user', 'Select role...'),
'multiple' => true,
],
'pluginOptions' => [
'allowClear' => true
],
])->label(false);
]
)->label(false);
?>
<h4><?= Yii::t('user', 'Permissions') ?></h4>
<?= $form->field($itemsForm, 'permissions')->widget(
Select2::classname(), [
Select2::class,
[
'name' => 'childrenPermissions',
'data' => $permissions,
'size' => Select2::SMALL,
'options' => ['placeholder' => Yii::t('user', 'Select permission...'), 'multiple' => true],
'options' => [
'placeholder' => Yii::t('user', 'Select permission...'),
'multiple' => true
],
'pluginOptions' => [
'allowClear' => true
],
])->label(false);
]
)->label(false);
?>
<div class="form-group">
@ -90,7 +101,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?php ActiveForm::end(); ?>
<?php else: ?>
<?php else : ?>
<div class="callout callout-warning">
<?= Yii::t('user', 'Administrator has full access rules') ?>
</div>

43
console/controllers/ModuleController.php

@ -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);
}
}
}

39
console/controllers/PermissionController.php

@ -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);
}
}

8
console/controllers/UserController.php

@ -31,8 +31,6 @@ class UserController extends Controller
$password = $this->prompt('Password:', ['required' => true]);
$role = $this->select('Role:', ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'));
//$this->findModel($username, $email);
$form = new UserForm();
$form->username = $username;
$form->email = $email;
@ -50,12 +48,6 @@ class UserController extends Controller
foreach ($form->errors as $error) {
$this->stdout(is_string($error) ? $error : $error[0] . PHP_EOL);
}
//$this->stdout(print_r($form->errors, true) . PHP_EOL);
/*
$user = User::create($username, $email, $phone, $password);
$user->save();*/
}
public function actionAddAdmin($username, $email, $password)

9
core/entities/Settings.php

@ -6,6 +6,10 @@
namespace core\entities;
use Yii;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
/**
* @property integer $id
* @property string $type
@ -17,10 +21,6 @@ namespace core\entities;
* @property integer $updated_at
*/
use Yii;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
class Settings extends ActiveRecord
{
public static function tableName(): string
@ -50,6 +50,7 @@ class Settings extends ActiveRecord
$settings->key = $key;
$settings->value = $value;
$settings->active = $active;
return $settings;
}

15
core/services/SettingsService.php

@ -8,11 +8,11 @@ use core\repositories\SettingsRepository;
class SettingsService
{
private $repository;
private $_repository;
public function __construct(SettingsRepository $repository)
{
$this->repository = $repository;
$this->_repository = $repository;
}
public function create(SettingsForm $form): Settings
@ -24,13 +24,14 @@ class SettingsService
$form->value,
$form->active
);
$this->repository->save($settings);
$this->_repository->save($settings);
return $settings;
}
public function edit($id, SettingsForm $form): void
{
$settings = $this->repository->get($id);
$settings = $this->_repository->get($id);
$settings->edit(
$form->type,
$form->section,
@ -38,12 +39,12 @@ class SettingsService
$form->value,
$form->active
);
$this->repository->save($settings);
$this->_repository->save($settings);
}
public function remove($id): void
{
$settings = $this->repository->get($id);
$this->repository->remove($settings);
$settings = $this->_repository->get($id);
$this->_repository->remove($settings);
}
}

1
core/services/user/UserManageService.php

@ -51,6 +51,7 @@ class UserManageService
$this->roles->assign($user->id, $form->role);
//$this->newsletter->subscribe($user->email);
});
return $user;
}

2
frontend/config/main.php

@ -35,7 +35,7 @@ return [
'session' => [
'name' => '_session',
'class' => 'yii\web\DbSession',
'writeCallback' => function($session){
'writeCallback' => function ($session) {
return [
'user_id' => Yii::$app->user->id
];

9
frontend/controllers/ContactController.php

@ -1,4 +1,5 @@
<?php
namespace frontend\controllers;
use core\services\ContactService;
@ -10,12 +11,12 @@ class ContactController extends FrontendController
{
public $layout = 'blank';
private $service;
private $_service;
public function __construct($id, $module, ContactService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
$this->_service = $service;
}
public function actionIndex()
@ -23,13 +24,15 @@ class ContactController extends FrontendController
$form = new ContactForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->send($form);
$this->_service->send($form);
Yii::$app->session->setFlash('success', Yii::t('main', 'Thank you for contacting us. We will respond to you as soon as possible.'));
return $this->goHome();
} catch (\Exception $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', Yii::t('main', 'There was an error sending your message.'));
}
return $this->refresh();
}

21
frontend/controllers/SiteController.php

@ -1,4 +1,5 @@
<?php
namespace frontend\controllers;
use core\forms\SubscribeForm;
@ -16,8 +17,9 @@ class SiteController extends FrontendController
{
public $newletter;
public function __construct( string $id, $module, Newsletter $newsletter, array $config = [] ) {
parent::__construct( $id, $module, $config );
public function __construct(string $id, $module, Newsletter $newsletter, array $config = [])
{
parent::__construct($id, $module, $config);
$this->newletter = $newsletter;
}
@ -72,6 +74,7 @@ class SiteController extends FrontendController
public function actionIndex()
{
$this->layout = 'home';
return $this->render('index');
}
@ -79,16 +82,16 @@ class SiteController extends FrontendController
{
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$form = new SubscribeForm();
if(Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())){
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
try {
$this->newletter->subscribe( $form->email );
return [ 'result' => 'success' ];
}
catch (\RuntimeException $e) {
return [ 'result' => 'error', 'message' => $e->getMessage() ];
$this->newletter->subscribe($form->email);
return ['result' => 'success'];
} catch (\RuntimeException $e) {
return ['result' => 'error', 'message' => $e->getMessage()];
}
}
return ['result' => 'error', 'message' => 'Request error'];
}
}

11
frontend/controllers/account/ProfileController.php

@ -6,7 +6,6 @@
namespace frontend\controllers\account;
use frontend\components\FrontendController;
use core\services\user\ProfileService;
use core\forms\user\ProfileEditForm;
@ -19,12 +18,12 @@ class ProfileController extends FrontendController
{
public $layout = 'profile';
private $service;
private $_service;
public function __construct($id, $module, ProfileService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
$this->_service = $service;
}
public function behaviors(): array
@ -55,14 +54,16 @@ class ProfileController extends FrontendController
$form = new ProfileEditForm($user);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($user->id, $form);
$this->_service->edit($user->id, $form);
Yii::$app->session->setFlash('success', Yii::t('user', 'Profile is saved.'));
return $this->redirect(['/account/profile/edit']);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('edit', [
'model' => $form,
'user' => $user,
@ -77,7 +78,9 @@ class ProfileController extends FrontendController
/**
* Finds the User model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @param integer $id
*
* @return User the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/

8
frontend/controllers/auth/AuthController.php

@ -1,4 +1,5 @@
<?php
namespace frontend\controllers\auth;
use common\auth\Identity;
@ -12,12 +13,12 @@ class AuthController extends Controller
{
public $layout = 'auth';
private $service;
private $_service;
public function __construct($id, $module, AuthService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
$this->_service = $service;
}
public function behaviors(): array
@ -57,8 +58,9 @@ class AuthController extends Controller
$form = new LoginForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$user = $this->service->auth($form);
$user = $this->_service->auth($form);
Yii::$app->user->login(new Identity($user), $form->rememberMe ? Yii::$app->params['user.rememberMeDuration'] : 0);
return $this->goBack();
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);

6
frontend/controllers/auth/NetworkController.php

@ -12,12 +12,12 @@ use yii\web\Controller;
class NetworkController extends Controller
{
private $service;
private $_service;
public function __construct($id, $module, NetworkService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
$this->_service = $service;
}
public function actions()
@ -37,7 +37,7 @@ class NetworkController extends Controller
$identity = ArrayHelper::getValue($attributes, 'id');
try {
$user = $this->service->auth($network, $identity);
$user = $this->_service->auth($network, $identity);
Yii::$app->user->login(new Identity($user), Yii::$app->params['user.rememberMeDuration']);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);

10
frontend/controllers/auth/ResetController.php

@ -12,12 +12,12 @@ class ResetController extends Controller
{
public $layout = 'auth';
private $service;
private $_service;
public function __construct($id, $module, PasswordResetService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
$this->_service = $service;
}
/**
@ -28,7 +28,7 @@ class ResetController extends Controller
$form = new PasswordResetRequestForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->request($form);
$this->_service->request($form);
Yii::$app->session->setFlash('success', Yii::t('auth', 'Check your email for further instructions.'));
return $this->goHome();
} catch (\DomainException $e) {
@ -50,7 +50,7 @@ class ResetController extends Controller
public function actionConfirm($token)
{
try {
$this->service->validateToken($token);
$this->_service->validateToken($token);
} catch (\DomainException $e) {
throw new BadRequestHttpException($e->getMessage());
}
@ -58,7 +58,7 @@ class ResetController extends Controller
$form = new ResetPasswordForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->reset($token, $form);
$this->_service->reset($token, $form);
Yii::$app->session->setFlash('success', Yii::t('auth', 'New password saved.'));
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);

15
frontend/controllers/auth/SignupController.php

@ -1,4 +1,5 @@
<?php
namespace frontend\controllers\auth;
use core\services\auth\SignupService;
@ -11,19 +12,19 @@ class SignupController extends Controller
{
public $layout = 'auth';
private $service;
private $_service;
public function __construct($id, $module, SignupService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
$this->_service = $service;
}
public function behaviors(): array
{
return [
'access' => [
'class' => AccessControl::className(),
'class' => AccessControl::class,
//'only' => ['index'],
'rules' => [
[
@ -44,8 +45,9 @@ class SignupController extends Controller
$form = new SignupForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->signup($form);
$this->_service->signup($form);
Yii::$app->session->setFlash('success', Yii::t('auth', 'Check your email for further instructions.'));
//return $this->goHome();
return $this->redirect(['auth/auth/login']);
} catch (\DomainException $e) {
@ -61,18 +63,21 @@ class SignupController extends Controller
/**
* @param $token
*
* @return mixed
*/
public function actionConfirm($token)
{
try {
$this->service->confirm($token);
$this->_service->confirm($token);
Yii::$app->session->setFlash('success', Yii::t('auth', 'Your email is confirmed.'));
return $this->redirect(['auth/auth/login']);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->goHome();
}
}

167
setup.php

@ -60,6 +60,10 @@ class Setup
'Admin account complete' => 'Аккаунт администратора создан',
'Prepare MySQL tables' => 'Подготовка MySQL таблиц',
'Complete' => 'Готово',
'Server HTTP configuration' => 'Конфигурация HTTP сервера',
'Does your server use Apache? [y]: ' => 'Ваш сервер использует Apache? [y]: ',
'Creating permissions' => 'Создание разрешений',
'Activating modules' => 'Активация модулей',
],
];
@ -95,6 +99,16 @@ class Setup
// setup domain data
$this->setConfigDomains();
// install modules
$this->activateSystemModules();
// install system permissions
$this->addPermissions();
// apache htaccess
$this->apache();
echo '---------------------' . PHP_EOL;
echo Console::log($this->l('Installation complete'), 'yellow') . PHP_EOL;
echo PHP_EOL;
@ -104,7 +118,7 @@ class Setup
echo '---------------------' . PHP_EOL;
}
private function selectType()
private function selectType() : void
{
echo '---------------------' . PHP_EOL;
echo Console::log($this->l('Select initialization type'), 'white') . PHP_EOL;
@ -114,7 +128,7 @@ class Setup
$this->_type = readline($this->l('Type [p]: ')) ?: 'p';
}
private function selectLanguage()
private function selectLanguage() : void
{
echo '---------------------' . PHP_EOL;
echo Console::log($this->l('Select installer language'), 'white') . PHP_EOL;
@ -124,7 +138,7 @@ class Setup
$this->_language = readline($this->l('Language [en]: ')) ?: 'en';
}
private function setupMySQL(): bool
private function setupMySQL() : bool
{
echo '---------------------' . PHP_EOL;
echo Console::log($this->l('MySQL settings'), 'white') . PHP_EOL;
@ -141,7 +155,7 @@ class Setup
return $this->checkDatabaseConnection();
}
private function checkDatabaseConnection(): bool
private function checkDatabaseConnection() : bool
{
try {
$this->_db_connection = new \PDO('mysql:host=' . $this->_db_host . ';dbname=' . $this->_db_name, $this->_db_user, $this->_db_pass);
@ -152,7 +166,7 @@ class Setup
}
}
private function setConfigMySQL()
private function setConfigMySQL() : void
{
$mysql_line = 'mysql:host=' . $this->_db_host . ';dbname=' . $this->_db_name;
$file = __DIR__ . '/common/config/main-local.php';
@ -163,7 +177,7 @@ class Setup
file_put_contents($file, $content);
}
private function setConfigDomains()
private function setConfigDomains() : void
{
echo '---------------------' . PHP_EOL;
echo Console::log($this->l('Set your HTTP protocol (http/https)'), 'white') . PHP_EOL;
@ -196,7 +210,7 @@ class Setup
file_put_contents($file, $content);
}
private function addAdmin(): void
private function addAdmin() : void
{
echo '---------------------' . PHP_EOL;
echo Console::log($this->l('Create admin account'), 'white') . PHP_EOL;
@ -227,13 +241,13 @@ class Setup
echo Console::log($this->l('Admin account complete'), 'green') . PHP_EOL;
}
private function trueEmail($email): bool
private function trueEmail($email) : bool
{
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
return $email ? true : false;
}
private function runMigrations(): void
private function runMigrations() : void
{
echo '---------------------' . PHP_EOL;
echo Console::log($this->l('Prepare MySQL tables'), 'white') . PHP_EOL;
@ -242,6 +256,141 @@ class Setup
echo Console::log($this->l('Complete'), 'green') . PHP_EOL;
}
private function apache() : void
{
echo '---------------------' . PHP_EOL;
echo Console::log($this->l('Server HTTP configuration'), 'white') . PHP_EOL;
echo '---------------------' . PHP_EOL;
$apache = readline($this->l('Does your server use Apache? [yes]: ')) ?: 'y';
if ($apache == 'y' || $apache == 'yes') {
$this->prepareHtaccess();
}
}
private function prepareHtaccess() : void
{
// main
$ssh_rules = <<<SSH
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://{$this->_domain}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(www\.)+(.*)$ [NC]
RewriteRule (.*) https://{$this->_domain}%{REQUEST_URI} [L,R=301]
SSH;
$ssh_rules = $this->_http_protocol == 'https' ? $ssh_rules : '';
$main_htacces = <<<MH
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
{$ssh_rules}
#static
RewriteCond %{HTTP_HOST} ^static.{$this->_domain}
RewriteRule ^(.*)$ zxcms/static/$1 [L]
#RewriteCond %{HTTP_HOST} ^static.{$this->_domain}
#RewriteRule ^(.*)$ $1 [L]
RewriteCond %{HTTP_HOST} ^admin.{$this->_domain}
RewriteRule ^(.*)$ zxcms/backend/web/$1 [L]
# if /admin - backend
RewriteCond %{HTTP_HOST} ^admin.{$this->_domain}
RewriteRule ^assets/(.*)$ zxcms/backend/web/assets/$1 [L]
RewriteCond %{HTTP_HOST} ^admin.{$this->_domain}
RewriteRule ^css/(.*)$ zxcms/backend/web/css/$1 [L]
RewriteCond %{HTTP_HOST} ^admin.{$this->_domain}
RewriteRule ^js/(.*)$ zxcms/backend/web/js/$1 [L]
RewriteCond %{REQUEST_URI} !^/zxcms/backend/web/(assets|js|css)/
RewriteCond %{HTTP_HOST} ^admin.{$this->_domain}
RewriteRule ^.*$ zxcms/backend/web/index.php [L]
#RewriteCond %{REQUEST_URI} !^/zxcms/static
RewriteCond %{REQUEST_URI} ^/(assets|css|js|images)
RewriteRule ^assets/(.*)$ zxcms/frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ zxcms/frontend/web/css/$1 [L]
RewriteRule ^js/(.*)$ zxcms/frontend/web/js/$1 [L]
RewriteRule ^images/(.*)$ zxcms/frontend/web/images/$1 [L]
RewriteRule ^(.*)$ zxcms/frontend/web/$1 [L]
#RewriteCond %{REQUEST_URI} !^/zxcms/static
RewriteCond %{REQUEST_URI} !^/zxcms/(frontend|backend)/web/(assets|css|js)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ zxcms/frontend/web/index.php
</IfModule>
MH;
file_put_contents(__DIR__ . '/../.htaccess', $main_htacces);
// backend, frontend
$bf_htaccess = <<<BF
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
BF;
file_put_contents(__DIR__ . '/backend/web/.htaccess', $bf_htaccess);
file_put_contents(__DIR__ . '/frontend/web/.htaccess', $bf_htaccess);
// static
$static_htaccess = <<<SH
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . {$this->_http_protocol}://{$this->_domain}/site/error [R=404,L]
ErrorDocument 404 {$this->_http_protocol}://{$this->_domain}/site/error
SH;
file_put_contents(__DIR__ . '/frontend/web/.htaccess', $static_htaccess);
}
private function addPermissions() : void
{
echo '---------------------' . PHP_EOL;
echo Console::log($this->l('Creating permissions'), 'white') . PHP_EOL;
echo '---------------------' . PHP_EOL;
$systemPermissions = [
'SettingsManagement' => 'Settings Management',
'MenuManagement' => 'Menu Management',
'ModuleManagement' => 'Modules Management',
'UserManagement' => 'Users Management',
'Dashboard' => 'Dashboard',
'SliderManagement' => 'Slider Management',
];
foreach ($systemPermissions as $name => $description) {
shell_exec('php ' . __DIR__ . '/yii permission/add "' . $name . '" "' . $description . '"');
}
echo Console::log($this->l('Complete'), 'green') . PHP_EOL;
}
private function activateSystemModules(): void
{
Console::log($this->l('Activating modules: '), 'white');
$systemModules = [
'languages', 'pages', 'forms', 'links'
];
foreach ($systemModules as $name) {
shell_exec('php ' . __DIR__ . '/yii module/add "' . $name . '"');
}
echo Console::log($this->l('Complete'), 'green') . PHP_EOL;
}
private function l($str): string
{
return isset($this->_l[$this->_language]) && isset($this->_l[$this->_language][$str]) ? $this->_l[$this->_language][$str] : $str;

Loading…
Cancel
Save