aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Component
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@smile.fr>2016-01-15 08:24:32 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-11 21:57:09 +0200
commit56c778b4152a1b886353933276ee3626e4e8c004 (patch)
tree203a2bc2fc36016b5a51703b04d86b034d9393c3 /src/Wallabag/ImportBundle/Component
parent59758d8fe5ad5ff554391515a78d84b0d47bdb76 (diff)
downloadwallabag-56c778b4152a1b886353933276ee3626e4e8c004.tar.gz
wallabag-56c778b4152a1b886353933276ee3626e4e8c004.tar.zst
wallabag-56c778b4152a1b886353933276ee3626e4e8c004.zip
1st draft for rabbitMQ
Diffstat (limited to 'src/Wallabag/ImportBundle/Component')
-rw-r--r--src/Wallabag/ImportBundle/Component/AMPQ/EntryConsumer.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Wallabag/ImportBundle/Component/AMPQ/EntryConsumer.php b/src/Wallabag/ImportBundle/Component/AMPQ/EntryConsumer.php
new file mode 100644
index 00000000..7775f01c
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Component/AMPQ/EntryConsumer.php
@@ -0,0 +1,39 @@
1<?php
2
3namespace Wallabag\ImportBundle\Component\AMPQ;
4
5use Doctrine\ORM\EntityManager;
6use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
7use PhpAmqpLib\Message\AMQPMessage;
8use Wallabag\CoreBundle\Helper\ContentProxy;
9use Wallabag\CoreBundle\Repository\EntryRepository;
10
11class EntryConsumer implements ConsumerInterface
12{
13 private $em;
14 private $contentProxy;
15 private $entryRepository;
16
17 public function __construct(EntityManager $em, EntryRepository $entryRepository, ContentProxy $contentProxy)
18 {
19 $this->em = $em;
20 $this->entryRepository = $entryRepository;
21 $this->contentProxy = $contentProxy;
22 }
23
24 /**
25 * {@inheritdoc}
26 */
27 public function execute(AMQPMessage $msg)
28 {
29 $storedEntry = unserialize($msg->body);
30 $entry = $this->entryRepository->findByUrlAndUserId($storedEntry['url'], $storedEntry['userId']);
31 if ($entry) {
32 $entry = $this->contentProxy->updateEntry($entry, $entry->getUrl());
33 if ($entry) {
34 $this->em->persist($entry);
35 $this->em->flush();
36 }
37 }
38 }
39}