diff options
Diffstat (limited to 'src/Wallabag/FederationBundle/Controller/RecommandController.php')
-rw-r--r-- | src/Wallabag/FederationBundle/Controller/RecommandController.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Wallabag/FederationBundle/Controller/RecommandController.php b/src/Wallabag/FederationBundle/Controller/RecommandController.php new file mode 100644 index 00000000..ea5a6660 --- /dev/null +++ b/src/Wallabag/FederationBundle/Controller/RecommandController.php | |||
@@ -0,0 +1,34 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\FederationBundle\Controller; | ||
4 | |||
5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | use Wallabag\CoreBundle\Entity\Entry; | ||
8 | use Wallabag\CoreBundle\Event\Activity\Actions\Federation\RecommendedEntryEvent; | ||
9 | use Wallabag\FederationBundle\Entity\Account; | ||
10 | |||
11 | class RecommandController extends Controller | ||
12 | { | ||
13 | /** | ||
14 | * @Route("/recommend/{entry}", name="recommend-entry") | ||
15 | * | ||
16 | * @param Entry $entry | ||
17 | */ | ||
18 | public function postRecommendAction(Entry $entry) | ||
19 | { | ||
20 | if ($entry->getUser() !== $this->getUser()) { | ||
21 | $this->createAccessDeniedException("You can't recommend entries which are not your own"); | ||
22 | } | ||
23 | $em = $this->getDoctrine()->getManager(); | ||
24 | |||
25 | $entry->setRecommended(true); | ||
26 | |||
27 | $em->persist($entry); | ||
28 | $em->flush(); | ||
29 | |||
30 | $this->get('event_dispatcher')->dispatch(RecommendedEntryEvent::NAME, new RecommendedEntryEvent($entry)); | ||
31 | |||
32 | $this->redirectToRoute('view', ['id' => $entry->getId()]); | ||
33 | } | ||
34 | } | ||