/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Event::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'plugin_id' => $this->plugin_id, 'app_id' => $this->app_id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'trigger_class', $this->trigger_class])->andFilterWhere(['like', 'trigger_event', $this->trigger_event])->andFilterWhere(['like', 'handler_method', $this->handler_method]);
     return $dataProvider;
 }
 /**
  * finds and creates app event manager from its settings
  * @param Application $app yii app
  * @return EventManager app event manager component
  * @throws Exception Define event manager
  */
 public static function getEventManager($app)
 {
     if (self::$_eventManager) {
         return self::$_eventManager;
     }
     foreach ($app->components as $name => $config) {
         $class = is_string($config) ? $config : @$config['class'];
         // if eventManager component in config
         if ($class == str_replace('Bootstrap', 'Manager', get_called_class())) {
             self::$_eventManager = $app->{$name}->events;
         }
         // this class. set $appId from config
         if ($class == str_replace('Manager', 'Bootstrap', get_called_class())) {
             if ($app->{$name}->appId) {
                 self::$appId = $app->{$name}->appId;
             }
         }
     }
     $events = ModelEvent::eventList(self::$appId);
     // merge config events with plugins
     self::$_eventManager = array_merge_recursive($events, self::$_eventManager);
     $app->setComponents(['eventManager' => ['class' => 'esoftslimited\\plugins\\components\\EventManager', 'events' => self::$_eventManager]]);
     return self::$_eventManager = $app->eventManager;
 }
 /**
  * Delete events
  * @param array $data
  * @return bool
  */
 protected function deleteEvent($data)
 {
     foreach (Event::find()->where($data)->all() as $event) {
         $event->delete();
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEvents()
 {
     return $this->hasMany(Event::className(), ['app_id' => 'id']);
 }
 /**
  * Finds the Event model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Event the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Event::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }