Commit 97801c8e authored by Tino Goratsch's avatar Tino Goratsch

minor improvements

parent 1cdc0f8b
......@@ -23,13 +23,13 @@ class Delete extends Core\Controller\AbstractAdminAction
/**
* Delete constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Comments\Model\Repository\CommentRepository $commentRepository
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Comments\Model\Repository\CommentRepository $commentRepository)
{
Comments\Model\Repository\CommentRepository $commentRepository
) {
parent::__construct($context);
$this->commentRepository = $commentRepository;
......@@ -44,16 +44,17 @@ class Delete extends Core\Controller\AbstractAdminAction
public function execute($action = '')
{
return $this->actionHelper->handleDeleteAction(
$action, function (array $items) {
$bool = false;
foreach ($items as $item) {
$bool = $this->commentRepository->delete($item, 'module_id');
}
$action,
function (array $items) {
$bool = false;
foreach ($items as $item) {
$bool = $this->commentRepository->delete($item, 'module_id');
}
Core\Cache\Purge::doPurge($this->appPath->getCacheDir() . 'http');
Core\Cache\Purge::doPurge($this->appPath->getCacheDir() . 'http');
return $bool;
}
return $bool;
}
);
}
}
......@@ -24,10 +24,6 @@ class Delete extends Core\Controller\AbstractAdminAction
* @var \ACP3\Modules\ACP3\Gallery\Helpers
*/
protected $galleryHelpers;
/**
* @var \ACP3\Modules\ACP3\Gallery\Model\Repository\GalleryRepository
*/
protected $galleryRepository;
/**
* @var \ACP3\Modules\ACP3\Gallery\Model\Repository\PictureRepository
*/
......@@ -36,29 +32,33 @@ class Delete extends Core\Controller\AbstractAdminAction
* @var \ACP3\Modules\ACP3\Seo\Helper\UriAliasManager
*/
protected $uriAliasManager;
/**
* @var Gallery\Model\GalleryModel
*/
protected $galleryModel;
/**
* Delete constructor.
*
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Gallery\Cache $galleryCache
* @param \ACP3\Modules\ACP3\Gallery\Helpers $galleryHelpers
* @param \ACP3\Modules\ACP3\Gallery\Model\Repository\GalleryRepository $galleryRepository
* @param \ACP3\Core\Controller\Context\AdminContext $context
* @param \ACP3\Modules\ACP3\Gallery\Cache $galleryCache
* @param \ACP3\Modules\ACP3\Gallery\Helpers $galleryHelpers
* @param Gallery\Model\GalleryModel $galleryModel
* @param \ACP3\Modules\ACP3\Gallery\Model\Repository\PictureRepository $pictureRepository
*/
public function __construct(
Core\Controller\Context\AdminContext $context,
Gallery\Cache $galleryCache,
Gallery\Helpers $galleryHelpers,
Gallery\Model\Repository\GalleryRepository $galleryRepository,
Gallery\Model\Repository\PictureRepository $pictureRepository)
{
Gallery\Model\GalleryModel $galleryModel,
Gallery\Model\Repository\PictureRepository $pictureRepository
) {
parent::__construct($context);
$this->galleryCache = $galleryCache;
$this->galleryHelpers = $galleryHelpers;
$this->galleryRepository = $galleryRepository;
$this->pictureRepository = $pictureRepository;
$this->galleryModel = $galleryModel;
}
/**
......@@ -77,11 +77,9 @@ class Delete extends Core\Controller\AbstractAdminAction
public function execute($action = '')
{
return $this->actionHelper->handleDeleteAction(
$action, function (array $items) {
$bool = false;
foreach ($items as $item) {
if (!empty($item) && $this->galleryRepository->galleryExists($item) === true) {
$action,
function (array $items) {
foreach ($items as $item) {
$pictures = $this->pictureRepository->getPicturesByGalleryId($item);
foreach ($pictures as $row) {
$this->galleryHelpers->removePicture($row['file']);
......@@ -96,15 +94,10 @@ class Delete extends Core\Controller\AbstractAdminAction
}
$this->deletePictureAliases($item);
$bool = $this->galleryRepository->delete($item);
}
}
Core\Cache\Purge::doPurge($this->appPath->getCacheDir() . 'http');
return $bool !== false;
}
return $this->galleryModel->delete($items);
}
);
}
......@@ -120,7 +113,10 @@ class Delete extends Core\Controller\AbstractAdminAction
$cPictures = count($pictures);
for ($i = 0; $i < $cPictures; ++$i) {
$this->uriAliasManager->deleteUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_PICTURE, $pictures[$i]['id']));
$this->uriAliasManager->deleteUriAlias(
sprintf(Gallery\Helpers::URL_KEY_PATTERN_PICTURE,
$pictures[$i]['id'])
);
}
}
......
......@@ -4,7 +4,7 @@ services:
arguments:
- '@core.context.admin'
- '@core.helpers.formToken'
- '@gallery.model'
- '@gallery.model.gallery_model'
- '@gallery.validator.gallery'
calls:
- ['setMetaFormFieldsHelper', ['@?seo.helper.meta_form_fields']]
......@@ -15,7 +15,7 @@ services:
- '@core.context.admin'
- '@gallery.cache'
- '@gallery.helpers'
- '@gallery.model.galleryrepository'
- '@gallery.model.gallery_model'
- '@gallery.model.picturerepository'
calls:
- ['setUriAliasManager', ['@?seo.helper.uri_alias_manager']]
......@@ -26,7 +26,7 @@ services:
- '@core.context.admin'
- '@core.helpers.formToken'
- '@gallery.model.picturerepository'
- '@gallery.model'
- '@gallery.model.gallery_model'
- '@gallery.validator.gallery'
calls:
- ['setAliases', ['@?seo.core.router.aliases']]
......
......@@ -14,7 +14,7 @@ services:
arguments:
- '@core.db'
gallery.model:
gallery.model.gallery_model:
class: ACP3\Modules\ACP3\Gallery\Model\GalleryModel
arguments:
- '@core.event_dispatcher'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment