/**
  * @return array|SourceMessage[]
  */
 public static function getCategories()
 {
     return SourceMessage::find()->select('category')->distinct('category')->asArray()->all();
 }
 /**
  * @param array|null $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SourceMessage::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     // check and populate params
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['messages']);
         return $dataProvider;
     }
     if ($this->status == static::STATUS_TRANSLATED) {
         $query->joinWith(['messages']);
         $query->translated();
     }
     if ($this->status == static::STATUS_NOT_TRANSLATED) {
         $query->joinWith(['messages']);
         $query->notTranslated();
     }
     if ($this->status == static::STATUS_DELETED) {
         $query->joinWith(['messages']);
         $query->deleted();
     }
     // search with related table
     // @see http://www.yiiframework.com/wiki/621/filter-sort-by-calculated-related-fields-in-gridview-yii-2-0/
     if (!empty($this->translation)) {
         $query->joinWith(['messages' => function ($q) {
             $q->where(['like', Message::tableName() . '.translation', $this->translation]);
         }]);
     }
     $query->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'message', $this->message]);
     return $dataProvider;
 }