/** * 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; }
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; }
/** * @return \yii\db\ActiveQuery */ public function getContentStopWords() { return $this->hasMany(ContentStopWords::className(), ['source_id' => 'id']); }
/** * 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.'); } }