aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php10
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php7
2 files changed, 12 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 8d2ac6d4..2a287825 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -9,12 +9,12 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\HttpFoundation\Request; 9use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 10use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
11use Wallabag\CoreBundle\Entity\Entry; 11use Wallabag\CoreBundle\Entity\Entry;
12use Wallabag\CoreBundle\Event\EntryUpdatedEvent;
12use Wallabag\CoreBundle\Form\Type\EntryFilterType; 13use Wallabag\CoreBundle\Form\Type\EntryFilterType;
13use Wallabag\CoreBundle\Form\Type\EditEntryType; 14use Wallabag\CoreBundle\Form\Type\EditEntryType;
14use Wallabag\CoreBundle\Form\Type\NewEntryType; 15use Wallabag\CoreBundle\Form\Type\NewEntryType;
15use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; 16use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
16use Wallabag\CoreBundle\Event\EntrySavedEvent; 17use Wallabag\CoreBundle\Event\EntrySavedEvent;
17use Wallabag\CoreBundle\Event\EntryDeletedEvent;
18use Wallabag\CoreBundle\Form\Type\SearchEntryType; 18use Wallabag\CoreBundle\Form\Type\SearchEntryType;
19 19
20class EntryController extends Controller 20class EntryController extends Controller
@@ -391,6 +391,7 @@ class EntryController extends Controller
391 $em->flush(); 391 $em->flush();
392 392
393 // entry saved, dispatch event about it! 393 // entry saved, dispatch event about it!
394 $this->get('event_dispatcher')->dispatch(EntryUpdatedEvent::NAME, new EntryUpdatedEvent($entry));
394 $this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry)); 395 $this->get('event_dispatcher')->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
395 396
396 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()])); 397 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
@@ -413,6 +414,8 @@ class EntryController extends Controller
413 $entry->toggleArchive(); 414 $entry->toggleArchive();
414 $this->getDoctrine()->getManager()->flush(); 415 $this->getDoctrine()->getManager()->flush();
415 416
417 $this->get('event_dispatcher')->dispatch(EntryUpdatedEvent::NAME, new EntryUpdatedEvent($entry));
418
416 $message = 'flashes.entry.notice.entry_unarchived'; 419 $message = 'flashes.entry.notice.entry_unarchived';
417 if ($entry->isArchived()) { 420 if ($entry->isArchived()) {
418 $message = 'flashes.entry.notice.entry_archived'; 421 $message = 'flashes.entry.notice.entry_archived';
@@ -445,6 +448,8 @@ class EntryController extends Controller
445 $entry->toggleStar(); 448 $entry->toggleStar();
446 $this->getDoctrine()->getManager()->flush(); 449 $this->getDoctrine()->getManager()->flush();
447 450
451 $this->get('event_dispatcher')->dispatch(EntryUpdatedEvent::NAME, new EntryUpdatedEvent($entry));
452
448 $message = 'flashes.entry.notice.entry_unstarred'; 453 $message = 'flashes.entry.notice.entry_unstarred';
449 if ($entry->isStarred()) { 454 if ($entry->isStarred()) {
450 $message = 'flashes.entry.notice.entry_starred'; 455 $message = 'flashes.entry.notice.entry_starred';
@@ -481,9 +486,6 @@ class EntryController extends Controller
481 UrlGeneratorInterface::ABSOLUTE_PATH 486 UrlGeneratorInterface::ABSOLUTE_PATH
482 ); 487 );
483 488
484 // entry deleted, dispatch event about it!
485 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
486
487 $em = $this->getDoctrine()->getManager(); 489 $em = $this->getDoctrine()->getManager();
488 $em->remove($entry); 490 $em->remove($entry);
489 $em->flush(); 491 $em->flush();
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index fb6a720b..e6d55931 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -9,6 +9,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\HttpFoundation\Request; 9use Symfony\Component\HttpFoundation\Request;
10use Wallabag\CoreBundle\Entity\Entry; 10use Wallabag\CoreBundle\Entity\Entry;
11use Wallabag\CoreBundle\Entity\Tag; 11use Wallabag\CoreBundle\Entity\Tag;
12use Wallabag\CoreBundle\Event\EntryTaggedEvent;
12use Wallabag\CoreBundle\Form\Type\NewTagType; 13use Wallabag\CoreBundle\Form\Type\NewTagType;
13use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 14use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
14 15
@@ -28,7 +29,7 @@ class TagController extends Controller
28 $form->handleRequest($request); 29 $form->handleRequest($request);
29 30
30 if ($form->isSubmitted() && $form->isValid()) { 31 if ($form->isSubmitted() && $form->isValid()) {
31 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry( 32 $tags = $this->get('wallabag_core.tags_assigner')->assignTagsToEntry(
32 $entry, 33 $entry,
33 $form->get('label')->getData() 34 $form->get('label')->getData()
34 ); 35 );
@@ -37,6 +38,8 @@ class TagController extends Controller
37 $em->persist($entry); 38 $em->persist($entry);
38 $em->flush(); 39 $em->flush();
39 40
41 $this->get('event_dispatcher')->dispatch(EntryTaggedEvent::NAME, new EntryTaggedEvent($entry, $tags));
42
40 $this->get('session')->getFlashBag()->add( 43 $this->get('session')->getFlashBag()->add(
41 'notice', 44 'notice',
42 'flashes.tag.notice.tag_added' 45 'flashes.tag.notice.tag_added'
@@ -64,6 +67,8 @@ class TagController extends Controller
64 $em = $this->getDoctrine()->getManager(); 67 $em = $this->getDoctrine()->getManager();
65 $em->flush(); 68 $em->flush();
66 69
70 $this->get('event_dispatcher')->dispatch(EntryTaggedEvent::NAME, new EntryTaggedEvent($entry, $tag));
71
67 // remove orphan tag in case no entries are associated to it 72 // remove orphan tag in case no entries are associated to it
68 if (count($tag->getEntries()) === 0) { 73 if (count($tag->getEntries()) === 0) {
69 $em->remove($tag); 74 $em->remove($tag);