public function actionRss() { Yii::$app->response->format = \yii\web\Response::FORMAT_RAW; $headers = Yii::$app->response->headers; $headers->add('Content-Type', 'text/xml'); $models = Hashtag::find()->orderBy("id desc")->limit(1000)->all(); return $this->renderPartial('rss', ['models' => $models]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Hashtag::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new \yii\data\Sort(['attributes' => ['id' => 'id']])]); $query->orderBy("id desc"); $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, 'active' => $this->active, 'created' => $this->created]); // $query->andFilterWhere(['like', 'tag', $this->tag]); return $dataProvider; }
/** * Finds the Hashtag model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Hashtag the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Hashtag::find()->where("tag = :tag", [':tag' => $id])->one()) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.')); } }
/** * @param $hashtagForSearch * * @return array */ public function findTweetByHashtag($hashtagForSearch) { $hashtags = Hashtag::find()->byHashtag($hashtagForSearch)->tweetsViaJunctionTable()->all(); return $this->composeTweets($hashtags); }