Beispiel #1
0
 /**
  * Saves the given media object to the db
  *
  * @param \Media\Model\Media $media
  *
  * @throws \Exception
  */
 public function saveMedia(Media $media)
 {
     $data = ['account_id' => $media->getAccountId(), 'title' => $media->getTitle(), 'url' => $media->getUrl(), 'date_posted' => $media->getDatePosted()];
     $id = (int) $media->getId();
     if ($id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getMedia($id)) {
             $this->tableGateway->update($data, ['id' => $id]);
         } else {
             throw new \Exception('Media id does not exist');
         }
     }
 }