]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/TagController.php
Save changes
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / TagController.php
index fb6a720b6e9d73d5b2608a505cf36a3a5836ed91..e6d55931ccbf52a1ea4937eae574a2b66c657d28 100644 (file)
@@ -9,6 +9,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Component\HttpFoundation\Request;
 use Wallabag\CoreBundle\Entity\Entry;
 use Wallabag\CoreBundle\Entity\Tag;
+use Wallabag\CoreBundle\Event\EntryTaggedEvent;
 use Wallabag\CoreBundle\Form\Type\NewTagType;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
 
@@ -28,7 +29,7 @@ class TagController extends Controller
         $form->handleRequest($request);
 
         if ($form->isSubmitted() && $form->isValid()) {
-            $this->get('wallabag_core.tags_assigner')->assignTagsToEntry(
+            $tags = $this->get('wallabag_core.tags_assigner')->assignTagsToEntry(
                 $entry,
                 $form->get('label')->getData()
             );
@@ -37,6 +38,8 @@ class TagController extends Controller
             $em->persist($entry);
             $em->flush();
 
+            $this->get('event_dispatcher')->dispatch(EntryTaggedEvent::NAME, new EntryTaggedEvent($entry, $tags));
+
             $this->get('session')->getFlashBag()->add(
                 'notice',
                 'flashes.tag.notice.tag_added'
@@ -64,6 +67,8 @@ class TagController extends Controller
         $em = $this->getDoctrine()->getManager();
         $em->flush();
 
+        $this->get('event_dispatcher')->dispatch(EntryTaggedEvent::NAME, new EntryTaggedEvent($entry, $tag));
+
         // remove orphan tag in case no entries are associated to it
         if (count($tag->getEntries()) === 0) {
             $em->remove($tag);