/** * Star or unstar based on current setting of starred * * @param TalkEntity $talk */ public function toggleStar($talk) { if ($talk->getStarred()) { list($status, $result) = $this->apiDelete($talk->getStarredUri(), []); if ($status == 200) { return ['starred' => false]; } } else { list($status, $result) = $this->apiPost($talk->getStarredUri(), []); if ($status == 201) { return ['starred' => true]; } } throw new \Exception("Failed to toggle star: {$status}, {$result}"); }
public function save(TalkEntity $talk) { $data = array('uri' => $talk->getApiUri(), 'title' => $talk->getTitle(), 'slug' => $talk->getUrlFriendlyTalkTitle(), 'verbose_uri' => $talk->getApiUri(true), 'event_uri' => $talk->getEventUri(), 'stub' => $talk->getStub()); $savedTalk = $this->load('uri', $talk->getApiUri()); if ($savedTalk) { // talk is already known - update this record $data = array_merge($savedTalk, $data); } $keys = array('event_uri' => $talk->getEventUri(), 'slug' => $talk->getUrlFriendlyTalkTitle()); $this->cache->saveByKeys($this->keyName, $data, $keys); $this->cache->save($this->keyName, $data, 'uri', $talk->getApiUri()); $this->cache->save($this->keyName, $data, 'stub', $talk->getStub()); }