예제 #1
0
 /**
  * Returns an array of items for a page.
  *
  * @param  int $offset Page offset
  * @param  int $itemCountPerPage Number of items per page
  *
  * @return array
  */
 public function getItems($offset, $itemCountPerPage)
 {
     $albumService = $this->getAlbumService();
     $photoService = $this->getPhotoService();
     $albums = $albumService->getAlbums($this->album, $offset, $itemCountPerPage);
     $photoCount = $itemCountPerPage - count($albums);
     $photoStart = max($offset - $this->album->getAlbumCount(), 0);
     $photos = $photoService->getPhotos($this->album, $photoStart, $photoCount);
     $items = array_merge($albums, $photos);
     return $items;
 }
예제 #2
0
 /**
  * Updates the dates on the parent album if it exists.
  *
  * @param \Photo\Model\Album $album
  */
 protected function albumPersisted($album)
 {
     $parent = $album->getParent();
     if (!is_null($parent) && !is_null($album->getStartDateTime())) {
         if (is_null($parent->getStartDateTime()) || $parent->getStartDateTime()->getTimestamp() > $album->getStartDateTime()->getTimeStamp()) {
             $parent->setStartDateTime($album->getStartDateTime());
         }
         if (is_null($parent->getEndDateTime()) || $parent->getEndDateTime()->getTimestamp() < $album->getEndDateTime()->getTimeStamp()) {
             $parent->setEndDateTime($album->getEndDateTime());
         }
     }
 }
예제 #3
0
 /**
  * Deletes the file belonging to the album cover for an album.
  *
  * @param \Photo\Model\Album $album
  */
 public function deleteAlbumCover($album)
 {
     $this->getPhotoService()->deletePhotoFile($album->getCoverPath());
 }
예제 #4
0
 /**
  * Add a sub album to an album.
  *
  * @param \Photo\Model\Album $album
  */
 public function addAlbum($album)
 {
     $album->setParent($this);
     $this->children[] = $album;
 }
예제 #5
0
 /**
  * Checks if the specified photo exists in the database already and returns
  * it if it does.
  *
  * @param string $path The storage path of the photo
  * @param \Photo\Model\Album $album the album the photo is in
  * @return \Photo\Model\Photo|null
  */
 public function getPhotoByData($path, $album)
 {
     return $this->getRepository()->findOneBy(['path' => $path, 'album' => $album->getId()]);
 }