Skip to content

Commit

Permalink
Merge pull request #21 from eluhr/feature/refurbish
Browse files Browse the repository at this point in the history
Feature/refurbish
  • Loading branch information
eluhr authored Jun 10, 2020
2 parents f19e6aa + 083523b commit 8587a69
Show file tree
Hide file tree
Showing 11 changed files with 391 additions and 100 deletions.
2 changes: 2 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Module extends \yii\base\Module
*/
public $modulesDashboardBlacklist = [];

public $rbacDiagramExcludeRoles = ['Master'];

/**
* @param $label
*
Expand Down
35 changes: 35 additions & 0 deletions src/controllers/CacheController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* @link http://www.diemeisterei.de/
* @copyright Copyright (c) 2020 diemeisterei GmbH, Stuttgart
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace dmstr\modules\backend\controllers;


use yii\web\Controller;
use Yii;

class CacheController extends Controller
{
/**
* flush cache
*
* if APCu is used as cache we cannot flush cache from cli command
* see: https://github.com/yiisoft/yii2/issues/8647
*
* @return \yii\web\Response
*/
public function actionFlush()
{
if (\Yii::$app->cache->flush()) {
\Yii::$app->session->addFlash('success', Yii::t('backend-module','Cache cleared'));
} else {
\Yii::$app->session->addFlash('error', Yii::t('backend-module','Cannot clear cache'));
}
return $this->redirect(['default/index']);
}
}
44 changes: 44 additions & 0 deletions src/controllers/ConfigController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php


namespace dmstr\modules\backend\controllers;


use dmstr\helpers\Metadata;
use yii\data\ArrayDataProvider;
use yii\web\Controller;
use Yii;

class ConfigController extends Controller
{
/**
* Application configuration.
*
* @return string
*/
public function actionView()
{
$loadedModules = Metadata::getModules();
$loadedModulesDataProvider = new ArrayDataProvider(['allModels' => $loadedModules]);
$loadedModulesDataProvider->pagination->pageSize = 100;

$components = Yii::$app->getComponents();
ksort($components);
$modules = Yii::$app->getModules();
ksort($modules);
$env = $_ENV;
ksort($env);


return $this->render(
'view',
[
'params' => Yii::$app->params,
'components' => $components,
'modules' => $modules,
'env' => $env,
'loadedModulesDataProvider' => $loadedModulesDataProvider,
]
);
}
}
94 changes: 1 addition & 93 deletions src/controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

namespace dmstr\modules\backend\controllers;

use dmstr\helpers\Metadata;
use dmstr\modules\backend\Module;
use dmstr\widgets\Menu;
use insolita\wgadminlte\InfoBox;
use Yii;
use yii\data\ArrayDataProvider;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\Controller;

/**
Expand Down Expand Up @@ -38,96 +35,6 @@ public function actionIndex()
return $this->render('index', ['items' => $items]);
}

/**
* Application configuration.
*
* @return string
*/
public function actionViewConfig()
{
$loadedModules = Metadata::getModules();
$loadedModulesDataProvider = new ArrayDataProvider(['allModels' => $loadedModules]);
$loadedModulesDataProvider->pagination->pageSize = 100;

$components = Yii::$app->getComponents();
ksort($components);
$modules = Yii::$app->getModules();
ksort($modules);

return $this->render(
'view-config',
[
'params' => Yii::$app->params,
'components' => $components,
'modules' => $modules,
'loadedModulesDataProvider' => $loadedModulesDataProvider,
]
);
}

/**
* @return string
*/
public function actionShowAuth()
{
$allPermissions = Yii::$app->authManager->getPermissions();
$allRoles = Yii::$app->authManager->getRoles();
$userPermissions = [];
$userRoles = [];

foreach ($allPermissions AS $item) {
if (Yii::$app->user->can($item->name)) {
$userPermissions[] = [
'description' => $item->description,
'name' => $item->name,
];
}
}
foreach ($allRoles AS $item) {
if (Yii::$app->user->can($item->name)) {
$userRoles[] = [
'description' => $item->description,
'name' => $item->name,
];
}
}

return $this->render('show-auth',
[
'permissions' => new ArrayDataProvider([
'allModels' => $userPermissions,
'pagination' => [
'pageSize' => 100,
],
]),
'roles' => new ArrayDataProvider([
'allModels' => $userRoles,
'pagination' => [
'pageSize' => 100,
],
]),
]);
}



/**
* flush cache
*
* if APCu is used as cache we cannot flush cache from cli command
* see: https://github.com/yiisoft/yii2/issues/8647
*
* @return \yii\web\Response
*/
public function actionCacheFlush()
{
if (Yii::$app->cache->flush()) {
Yii::$app->session->addFlash('success', Yii::t('backend-module','Cache cleared'));
} else {
Yii::$app->session->addFlash('error', Yii::t('backend-module','Cannot clear cache'));
}
return $this->redirect(!empty(Yii::$app->request->referrer) ? Yii::$app->request->referrer : Url::to(['index']));
}


/**
Expand Down Expand Up @@ -167,4 +74,5 @@ public function renderDashboardMenu($item = [])

return $menuItems;
}

}
Loading

0 comments on commit 8587a69

Please sign in to comment.