public function actionIndex($removeTopic = 0) { $topicData = Topic::find()->all(); foreach ($topicData as $topic) { $this->actionLocal($topic->id, $removeTopic); } return 0; }
/** * @return \yii\db\ActiveQuery */ public function getTopic() { return $this->hasOne(Topic::className(), ['id' => 'topic_id']); }
/** * @return \yii\db\ActiveQuery */ public function getTopics() { return $this->hasMany(Topic::className(), ['id' => 'topic_id'])->viaTable('scoopit_topic_tag', ['tag_id' => 'id']); }
private function _syncTopi2c($topic, $publish) { $model = Topic::findOne($topic['id']); //Create a new model if required if (!isset($model)) { $this->stdout('creating topic #' . $topic['id'] . ' with name ' . $topic['name'] . "\n"); $model = new Topic(['id' => $topic['id'], 'name' => $topic['name'], 'is_published' => $publish]); if (!$model->save()) { VarDumper::dump($model->errors); return false; } //Sync names if scoop.it name has changed (existing model only) } elseif ($model->name != $topic['name']) { $this->stdout('changing short name #' . $topic['id'] . ': ' . $model->name . ' to ' . $topic['name'] . "\n"); $model->name = $topic['name']; return $model->save(); } return true; }
public function linkTopic($topicId) { $topic = Topic::findOne($topicId); if (!isset($topic)) { return false; } $out = [true, $topic]; try { $model = new SourceTopic(['topic_id' => $topicId, 'source_id' => $this->id]); if (isset($this->topicPostProcessor)) { $model->postProcessor = $this->topicPostProcessor; } $out[0] = $model->save(); } catch (\Exception $ex) { // echo $ex->getMessage(); $out[0] = false; } return $out; }
public function peek($topicId, $mode = 1) { $topic = \humanized\scoopit\models\Topic::findOne(!is_numeric($topicId) ? ['name' => $topicId] : $topicId); if (NULL === $topic) { $this->stdout("No Such Topic \n"); return 1; } $client = new Client(); }