コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function save(Album $album)
 {
     $data = $album->getArrayCopy();
     if (null === $album->getId()) {
         return $this->db->insert('album', $data);
     } else {
         return $this->db->update('album', ['artist' => $data['artist'], 'title' => $data['title']], ['id' => $data['id']]);
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function addAlbum(array $data)
 {
     $this->form->setData($data);
     if ($this->form->isValid()) {
         $album = new Album();
         $album->exchangeArray($data);
         if (!$this->repository->save($album)) {
             throw new \Exception('Unable to save the album');
         }
         return true;
     }
     return false;
 }
コード例 #3
0
 /**
  * @param Album $album
  * @return int
  */
 public function delete(Album $album)
 {
     return $this->db->delete('album', ['id' => $album->getId()]);
 }