/** * Removes an album by its associated id * * @param string $albumId * @return boolean */ private function removeAlbumById($albumId) { $this->albumMapper->deleteById($albumId); $this->removeWebPage($albumId); // Grab all photos associated with target album id $photosIds = $this->photoMapper->fetchPhotoIdsByAlbumId($albumId); // Do batch removal if album has at least one photo if (!empty($photosIds)) { foreach ($photosIds as $photoId) { // Remove a photo $this->imageManager->delete($photoId) && $this->photoMapper->deleteById($photoId); } } $this->albumPhoto->delete($albumId); return true; }
/** * Fetches all photos * * @param boolean $published Whether to filter by published attribute * @param string $albumId Optional album id filter * @return array */ public function fetchAll($published, $albumId = null) { return $this->prepareResults($this->photoMapper->fetchAll($published, $albumId)); }
/** * Gets photos count by their album id * * @param string $albumId * @return integer */ public function getCountByAlbumId($albumId) { return $this->photoMapper->countAllByAlbumId($albumId); }