/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['position' => SORT_ASC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 /**
  * Returns a tree of all items, grouped by menu, formatted for usage in a
  * Html::dropDownList widget
  *
  * @return  array
  */
 public function getAllForDropDownList($language = null)
 {
     $language = $language ?: Yii::$app->language;
     $items = [];
     foreach (Menu::find()->all() as $menu) {
         $items[$menu->name] = $menu->getAllForDropDownList(0, $language);
     }
     return $items;
 }
 protected function findActiveMenu()
 {
     // If no valid active menu-id is set, search the first menu and use it's id
     if (in_array(Yii::$app->session->get('menu-items.menu-id'), [0, null])) {
         $menu = Menu::find()->one();
         Yii::$app->session->set('menu-items.menu-id', $menu->id);
     } else {
         $menu = Menu::findone(Yii::$app->session->get('menu-items.menu-id'));
     }
     return $menu;
 }
 /**
  * Returns an array of the default params that are passed to a view
  *
  * @param Page $model The model that has to be passed to the view
  * @return array
  */
 protected function getDefaultViewParams($model = null)
 {
     return ['model' => $model, 'templates' => $this->getTemplates(), 'sliders' => $this->module->enableSliders ? ArrayHelper::map(\infoweb\sliders\models\Slider::find()->select(['id', 'name'])->orderBy('name')->all(), 'id', 'name') : [], 'forms' => $this->module->enableForm ? ArrayHelper::map(\infoweb\form\models\form\FormLang::find()->select(['form_id', 'name'])->where(['=', 'language', Yii::$app->language])->orderBy('name')->all(), 'form_id', 'name') : [], 'menus' => $this->module->enableMenu ? ArrayHelper::map(\infoweb\menu\models\Menu::find()->select(['id', 'name'])->orderBy('name')->all(), 'id', 'name') : [], 'allowContentDuplication' => $this->module->allowContentDuplication];
 }