Commit 70f8fede authored by Tino Goratsch's avatar Tino Goratsch

update the results cache via the gallery.model.gallery_pictures.after_save...

update the results cache via the gallery.model.gallery_pictures.after_save event of the gallery module
parent 03e991bf
......@@ -27,10 +27,6 @@ class Create extends AbstractFormAction
* @var \ACP3\Modules\ACP3\Gallery\Model\Repository\GalleryRepository
*/
protected $galleryRepository;
/**
* @var \ACP3\Modules\ACP3\Gallery\Cache
*/
protected $galleryCache;
/**
* @var \ACP3\Modules\ACP3\Gallery\Validation\PictureFormValidation
*/
......@@ -65,7 +61,6 @@ class Create extends AbstractFormAction
* @param \ACP3\Modules\ACP3\Gallery\Model\Repository\GalleryRepository $galleryRepository
* @param \ACP3\Modules\ACP3\Gallery\Model\Repository\PictureRepository $pictureRepository
* @param Gallery\Model\PictureModel $pictureModel
* @param \ACP3\Modules\ACP3\Gallery\Cache $galleryCache
* @param \ACP3\Modules\ACP3\Gallery\Validation\PictureFormValidation $pictureFormValidation
*/
public function __construct(
......@@ -75,7 +70,6 @@ class Create extends AbstractFormAction
Gallery\Model\Repository\GalleryRepository $galleryRepository,
Gallery\Model\Repository\PictureRepository $pictureRepository,
Gallery\Model\PictureModel $pictureModel,
Gallery\Cache $galleryCache,
Gallery\Validation\PictureFormValidation $pictureFormValidation
) {
parent::__construct($context, $formsHelper);
......@@ -83,7 +77,6 @@ class Create extends AbstractFormAction
$this->formTokenHelper = $formTokenHelper;
$this->galleryRepository = $galleryRepository;
$this->pictureRepository = $pictureRepository;
$this->galleryCache = $galleryCache;
$this->pictureFormValidation = $pictureFormValidation;
$this->pictureModel = $pictureModel;
}
......@@ -174,8 +167,6 @@ class Create extends AbstractFormAction
$bool2 = $this->generatePictureAlias($lastId);
$this->galleryCache->saveCache($galleryId);
return $lastId && $bool2;
},
'acp/gallery/index/edit/id_' . $galleryId
......
......@@ -24,10 +24,6 @@ class Edit extends AbstractFormAction
* @var \ACP3\Modules\ACP3\Gallery\Helpers
*/
protected $galleryHelpers;
/**
* @var \ACP3\Modules\ACP3\Gallery\Cache
*/
protected $galleryCache;
/**
* @var \ACP3\Modules\ACP3\Gallery\Validation\PictureFormValidation
*/
......@@ -50,7 +46,6 @@ class Edit extends AbstractFormAction
* @param \ACP3\Modules\ACP3\Gallery\Helpers $galleryHelpers
* @param \ACP3\Modules\ACP3\Gallery\Model\Repository\PictureRepository $pictureRepository
* @param Gallery\Model\PictureModel $pictureModel
* @param \ACP3\Modules\ACP3\Gallery\Cache $galleryCache
* @param \ACP3\Modules\ACP3\Gallery\Validation\PictureFormValidation $pictureFormValidation
*/
public function __construct(
......@@ -60,7 +55,6 @@ class Edit extends AbstractFormAction
Gallery\Helpers $galleryHelpers,
Gallery\Model\Repository\PictureRepository $pictureRepository,
Gallery\Model\PictureModel $pictureModel,
Gallery\Cache $galleryCache,
Gallery\Validation\PictureFormValidation $pictureFormValidation
) {
parent::__construct($context, $formsHelper);
......@@ -68,7 +62,6 @@ class Edit extends AbstractFormAction
$this->formTokenHelper = $formTokenHelper;
$this->galleryHelpers = $galleryHelpers;
$this->pictureRepository = $pictureRepository;
$this->galleryCache = $galleryCache;
$this->pictureFormValidation = $pictureFormValidation;
$this->pictureModel = $pictureModel;
}
......@@ -145,11 +138,7 @@ class Edit extends AbstractFormAction
$formData['file'] = $result['name'];
}
$bool = $this->pictureModel->savePicture($formData, $picture['gallery_id'], $pictureId);
$this->galleryCache->saveCache($picture['gallery_id']);
return $bool;
return $this->pictureModel->savePicture($formData, $picture['gallery_id'], $pictureId);
},
'acp/gallery/index/edit/id_' . $picture['gallery_id']
);
......
<?php
/**
* Copyright (c) 2016 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Modules\ACP3\Gallery\Event\Listener;
use ACP3\Core\Model\Event\ModelSaveEvent;
use ACP3\Modules\ACP3\Gallery\Cache;
class UpdatePictureCacheOnModelAfterSaveListener
{
/**
* @var Cache
*/
protected $cache;
/**
* UpdatePictureCacheOnModelAfterSaveListener constructor.
* @param Cache $cache
*/
public function __construct(Cache $cache)
{
$this->cache = $cache;
}
/**
* @param ModelSaveEvent $event
*/
public function execute(ModelSaveEvent $event)
{
$data = $event->getData();
$this->cache->saveCache($data['gallery_id']);
}
}
......@@ -57,7 +57,6 @@ services:
- '@gallery.model.galleryrepository'
- '@gallery.model.picturerepository'
- '@gallery.model.picture_model'
- '@gallery.cache'
- '@gallery.validator.picture'
calls:
- ['setAliases', ['@?seo.core.router.aliases']]
......@@ -83,7 +82,6 @@ services:
- '@gallery.helpers'
- '@gallery.model.picturerepository'
- '@gallery.model.picture_model'
- '@gallery.cache'
- '@gallery.validator.picture'
gallery.controller.admin.pictures.order:
......
services:
gallery.event.update_picture_cache_on_model_after_save_listener:
class: ACP3\Modules\ACP3\Gallery\Event\Listener\UpdatePictureCacheOnModelAfterSaveListener
arguments:
- '@gallery.cache'
tags:
- { name: core.eventListener, event: gallery.model.gallery_pictures.after_save, method: execute }
imports:
- { resource: components/cache.yml }
- { resource: components/controllers.yml }
- { resource: components/events.yml }
- { resource: components/installer.yml }
- { resource: components/models.yml }
- { resource: components/validation.yml }
......
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