/** * * @param integer|string $topicId */ public function actionRemote($topicId) { $topic = \humanized\scoopit\models\Topic::findOne(!is_numeric($topicId) ? ['name' => $topicId] : $topicId); if (NULL === $topic) { $this->stdout("No Such Topic \n"); return 1; } $queryParams = ['action' => 'delete']; $client = new Client(); foreach ($client->getScoops($topic->id) as $remoteScoop) { $queryParams['id'] = $remoteScoop->id; $client->post('api/1/post', ['query' => $queryParams]); } }
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; }
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 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(); }