Пример #1
0
 /**
  * @inheritdoc
  */
 public static function getDb()
 {
     if (Configs::instance()->db !== null) {
         return Configs::instance()->db;
     } else {
         return parent::getDb();
     }
 }
Пример #2
0
 /**
  * Ivalidate cache
  */
 protected function invalidate()
 {
     if (Configs::instance()->cache !== null) {
         TagDependency::invalidate(Configs::instance()->cache, self::CACHE_TAG);
     }
 }
 /**
  * @inheritdoc
  */
 public function safeDown()
 {
     $this->dropTable(Configs::instance()->menuTable);
 }
Пример #4
0
 /**
  * Get avalible menu.
  * @return array
  */
 public function getMenus()
 {
     if ($this->_normalizeMenus === null) {
         $mid = '/' . $this->getUniqueId() . '/';
         // resolve core menus
         $this->_normalizeMenus = [];
         $config = components\Configs::instance();
         foreach ($this->_coreItems as $id => $lable) {
             if ($id !== 'menu' || $config->db !== null && $config->db->schema->getTableSchema($config->menuTable) !== null) {
                 $this->_normalizeMenus[$id] = ['label' => Yii::t('rbac-admin', $lable), 'url' => [$mid . $id]];
             }
         }
         foreach (array_keys($this->controllerMap) as $id) {
             $this->_normalizeMenus[$id] = ['label' => Yii::t('rbac-admin', Inflector::humanize($id)), 'url' => [$mid . $id]];
         }
         // user configure menus
         foreach ($this->_menus as $id => $value) {
             if (empty($value)) {
                 unset($this->_normalizeMenus[$id]);
             } else {
                 if (is_string($value)) {
                     $value = ['label' => $value];
                 }
                 $this->_normalizeMenus[$id] = isset($this->_normalizeMenus[$id]) ? array_merge($this->_normalizeMenus[$id], $value) : $value;
                 if (!isset($this->_normalizeMenus[$id]['url'])) {
                     $this->_normalizeMenus[$id]['url'] = [$mid . $id];
                 }
             }
         }
     }
     return $this->_normalizeMenus;
 }