mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-27 17:28:39 +00:00
Use custom event instead of Doctrine ones
This give us ability to use Entry ID to determine where to store images and it’s then more easy to remove them when we remove the entry.
This commit is contained in:
parent
aedd6ca0fd
commit
e0597476d1
8 changed files with 211 additions and 135 deletions
|
@ -13,6 +13,8 @@ use Wallabag\CoreBundle\Form\Type\EntryFilterType;
|
|||
use Wallabag\CoreBundle\Form\Type\EditEntryType;
|
||||
use Wallabag\CoreBundle\Form\Type\NewEntryType;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
|
||||
use Wallabag\CoreBundle\Event\EntrySavedEvent;
|
||||
use Wallabag\CoreBundle\Event\EntryDeletedEvent;
|
||||
|
||||
class EntryController extends Controller
|
||||
{
|
||||
|
@ -81,6 +83,9 @@ class EntryController extends Controller
|
|||
$em->persist($entry);
|
||||
$em->flush();
|
||||
|
||||
// entry saved, dispatch event about it!
|
||||
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
||||
|
||||
return $this->redirect($this->generateUrl('homepage'));
|
||||
}
|
||||
|
||||
|
@ -107,6 +112,9 @@ class EntryController extends Controller
|
|||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($entry);
|
||||
$em->flush();
|
||||
|
||||
// entry saved, dispatch event about it!
|
||||
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
||||
}
|
||||
|
||||
return $this->redirect($this->generateUrl('homepage'));
|
||||
|
@ -343,6 +351,9 @@ class EntryController extends Controller
|
|||
$em->persist($entry);
|
||||
$em->flush();
|
||||
|
||||
// entry saved, dispatch event about it!
|
||||
$this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
||||
|
||||
return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
|
||||
}
|
||||
|
||||
|
@ -431,6 +442,9 @@ class EntryController extends Controller
|
|||
UrlGeneratorInterface::ABSOLUTE_PATH
|
||||
);
|
||||
|
||||
// entry deleted, dispatch event about it!
|
||||
$this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($entry);
|
||||
$em->flush();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue