Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ContentStopWords::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if ($this->load($params) && !$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'source_id' => $this->source_id]);
     $query->andFilterWhere(['like', 'word', $this->word]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 private function processContentStopWords($content)
 {
     foreach (ContentStopWords::findAll(["source_id" => $this->source->id]) as $csw) {
         if ($pos = mb_strpos($content, $csw->word, null, "utf-8")) {
             $content = mb_substr($content, 0, $pos, "utf-8");
         }
     }
     return $content;
 }
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getContentStopWords()
 {
     return $this->hasMany(ContentStopWords::className(), ['source_id' => 'id']);
 }
Ejemplo n.º 4
0
 /**
  * Finds the ContentStopWords model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id
  *
  * @return ContentStopWords the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ContentStopWords::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }