Exemplo n.º 1
0
 public function moduleEventList()
 {
     $attributes = ['trigger_class', 'trigger_event', 'handler_class', 'handler_method'];
     $order = array_combine($attributes, array_fill(0, count($attributes), SORT_ASC));
     $allEvents = Item::find()->where(['active' => 1])->select($attributes)->orderBy($order)->asArray()->all();
     $result = [];
     foreach ($allEvents as $data) {
         $result[$data['trigger_class']][$data['trigger_event']][] = [$data['handler_class'], $data['handler_method']];
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Item::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->defaultOrder = ['trigger_class' => SORT_ASC, 'trigger_event' => SORT_ASC, 'handler_class' => SORT_ASC, 'handler_method' => SORT_ASC];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'trigger_class', $this->trigger_class])->andFilterWhere(['like', 'trigger_event', $this->trigger_event])->andFilterWhere(['like', 'handler_class', $this->handler_class])->andFilterWhere(['like', 'handler_method', $this->handler_method]);
     return $dataProvider;
 }