/** * @param int $id * * @return array * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($id) { if ($this->galleryRepository->galleryExists($id, $this->date->getCurrentDateTime()) === true) { $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']); $this->breadcrumb->append($this->translator->t('gallery', 'gallery'), 'gallery')->append($this->galleryRepository->getGalleryTitle($id)); return ['pictures' => $this->galleryCache->getCache($id), 'overlay' => (int) $this->settings['overlay']]; } throw new Core\Controller\Exception\ResultNotExistsException(); }
/** * @param int $id * @param string $action * * @return \Symfony\Component\HttpFoundation\RedirectResponse * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($id, $action) { if (($action === 'up' || $action === 'down') && $this->pictureRepository->pictureExists($id) === true) { if ($action === 'up') { $this->sortHelper->up(Gallery\Model\Repository\PictureRepository::TABLE_NAME, 'id', 'pic', $id, 'gallery_id'); } else { $this->sortHelper->down(Gallery\Model\Repository\PictureRepository::TABLE_NAME, 'id', 'pic', $id, 'gallery_id'); } $galleryId = $this->pictureRepository->getGalleryIdFromPictureId($id); $this->galleryCache->saveCache($galleryId); Core\Cache\Purge::doPurge($this->appPath->getCacheDir() . 'http'); return $this->redirect()->temporary('acp/gallery/index/edit/id_' . $galleryId); } throw new Core\Controller\Exception\ResultNotExistsException(); }
/** * @param string $action * * @return mixed */ public function execute($action = '') { return $this->actionHelper->handleDeleteAction($action, function (array $items) { foreach ($items as $item) { $pictures = $this->pictureRepository->getPicturesByGalleryId($item); foreach ($pictures as $row) { $this->galleryHelpers->removePicture($row['file']); } $this->galleryCache->getCacheDriver()->delete(Gallery\Cache::CACHE_ID . $item); if ($this->uriAliasManager) { $this->uriAliasManager->deleteUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $item)); } $this->deletePictureAliases($item); } return $this->galleryModel->delete($items); }); }
/** * @param int $id * @param string $action * * @return mixed * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($id, $action = '') { return $this->actionHelper->handleDeleteAction($action, function (array $items) { $bool = false; foreach ($items as $item) { if (!empty($item) && $this->pictureRepository->pictureExists($item) === true) { $picture = $this->pictureRepository->getOneById($item); $this->pictureRepository->updatePicturesNumbers($picture['pic'], $picture['gallery_id']); $this->galleryHelpers->removePicture($picture['file']); $bool = $this->pictureRepository->delete($item); if ($this->uriAliasManager) { $this->uriAliasManager->deleteUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_PICTURE, $item)); } $this->galleryCache->saveCache($picture['gallery_id']); } } Core\Cache\Purge::doPurge($this->appPath->getCacheDir() . 'http'); return $bool; }, 'acp/gallery/pictures/delete/id_' . $id, 'acp/gallery/index/edit/id_' . $id); }
/** * @param ModelSaveEvent $event */ public function execute(ModelSaveEvent $event) { $data = $event->getData(); $this->cache->saveCache($data['gallery_id']); }