Example #1
0
 /**
  * Get core menu
  * @return array
  * @var $ids array has 'Menu Lable' => 'Controller' pairs
  */
 protected function getCoreMenus()
 {
     $mid = '/' . $this->getUniqueId() . '/';
     $ids = ['Assignments' => 'assignment', 'Roles' => 'role', 'Permissions' => 'permission', 'Routes' => 'route', 'Rules' => 'rule', 'Menus' => 'menu'];
     $config = components\Configs::instance();
     $result = [];
     foreach ($ids as $lable => $id) {
         if ($id !== 'menu' || $config->db !== null && $config->db->schema->getTableSchema($config->menuTable) !== null) {
             $result[$id] = ['label' => Yii::t('rbac-admin', $lable), 'url' => [$mid . $id]];
         }
     }
     foreach (array_keys($this->controllerMap) as $id) {
         $result[$id] = ['label' => Yii::t('rbac-admin', Inflector::humanize($id)), 'url' => [$mid . $id]];
     }
     return $result;
 }
Example #2
0
 /**
  * Use to invalidate cache.
  */
 public static function invalidate()
 {
     if (Configs::instance()->cache !== null) {
         TagDependency::invalidate(Configs::instance()->cache, self::CACHE_TAG);
     }
 }
 /**
  * @inheritdoc
  */
 public function safeDown()
 {
     $this->dropTable(Configs::instance()->menuTable);
 }
Example #4
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['men_nombre'], 'required'], [['parent_name'], 'filterParent'], [['parent_name'], 'in', 'range' => static::find()->select(['men_nombre'])->column(), 'message' => 'Menu "{value}" no encontrado.'], [['men_modulo'], 'in', 'range' => Configs::getModules(), 'message' => 'Modulo "{value}" no encontrado.'], [['men_parent', 'men_url', 'men_data', 'men_orden', 'men_modulo'], 'default'], [['men_orden'], 'integer'], [['men_url'], 'in', 'range' => static::getSavedRoutes(), 'message' => 'Url "{value}" no encontrada.']];
 }
Example #5
0
<div class="menu-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'men_nombre')->textInput(['maxlength' => 128]);
?>

    <?php 
echo $form->field($model, 'parent_name')->widget('yii\\jui\\AutoComplete', ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Menu::find()->select(['men_nombre'])->column()]]);
?>

    <?php 
echo $form->field($model, 'men_modulo')->widget('yii\\jui\\AutoComplete', ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Configs::getModules()]]);
?>

    <?php 
echo $form->field($model, 'men_url')->widget('yii\\jui\\AutoComplete', ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Menu::getSavedRoutes()]]);
?>

    <?php 
echo $form->field($model, 'men_orden')->input('number');
?>

    <?php 
echo $form->field($model, 'men_data')->textarea(['rows' => 4]);
?>

    <div class="form-group">