aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller')
-rw-r--r--src/Wallabag/ImportBundle/Controller/PocketController.php25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php
index 36ee25bf..a2dcd8a7 100644
--- a/src/Wallabag/ImportBundle/Controller/PocketController.php
+++ b/src/Wallabag/ImportBundle/Controller/PocketController.php
@@ -11,11 +11,28 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
11class PocketController extends Controller 11class PocketController extends Controller
12{ 12{
13 /** 13 /**
14 * Return Pocket Import Service with or without RabbitMQ enabled.
15 *
16 * @return \Wallabag\ImportBundle\Import\PocketImport
17 */
18 private function getPocketImportService()
19 {
20 $pocket = $this->get('wallabag_import.pocket.import');
21 $pocket->setUser($this->getUser());
22
23 if ($this->get('craue_config')->get('rabbitmq')) {
24 $pocket->setRabbitmqProducer($this->get('old_sound_rabbit_mq.wallabag_pocket_producer'));
25 }
26
27 return $pocket;
28 }
29
30 /**
14 * @Route("/pocket", name="import_pocket") 31 * @Route("/pocket", name="import_pocket")
15 */ 32 */
16 public function indexAction() 33 public function indexAction()
17 { 34 {
18 $pocket = $this->get('wallabag_import.pocket.import'); 35 $pocket = $this->getPocketImportService();
19 $form = $this->createFormBuilder($pocket) 36 $form = $this->createFormBuilder($pocket)
20 ->add('mark_as_read', CheckboxType::class, [ 37 ->add('mark_as_read', CheckboxType::class, [
21 'label' => 'import.form.mark_as_read_label', 38 'label' => 'import.form.mark_as_read_label',
@@ -24,7 +41,7 @@ class PocketController extends Controller
24 ->getForm(); 41 ->getForm();
25 42
26 return $this->render('WallabagImportBundle:Pocket:index.html.twig', [ 43 return $this->render('WallabagImportBundle:Pocket:index.html.twig', [
27 'import' => $this->get('wallabag_import.pocket.import'), 44 'import' => $this->getPocketImportService(),
28 'has_consumer_key' => '' == trim($this->get('craue_config')->get('pocket_consumer_key')) ? false : true, 45 'has_consumer_key' => '' == trim($this->get('craue_config')->get('pocket_consumer_key')) ? false : true,
29 'form' => $form->createView(), 46 'form' => $form->createView(),
30 ]); 47 ]);
@@ -35,7 +52,7 @@ class PocketController extends Controller
35 */ 52 */
36 public function authAction(Request $request) 53 public function authAction(Request $request)
37 { 54 {
38 $requestToken = $this->get('wallabag_import.pocket.import') 55 $requestToken = $this->getPocketImportService()
39 ->getRequestToken($this->generateUrl('import', [], UrlGeneratorInterface::ABSOLUTE_URL)); 56 ->getRequestToken($this->generateUrl('import', [], UrlGeneratorInterface::ABSOLUTE_URL));
40 57
41 if (false === $requestToken) { 58 if (false === $requestToken) {
@@ -62,7 +79,7 @@ class PocketController extends Controller
62 public function callbackAction() 79 public function callbackAction()
63 { 80 {
64 $message = 'flashes.import.notice.failed'; 81 $message = 'flashes.import.notice.failed';
65 $pocket = $this->get('wallabag_import.pocket.import'); 82 $pocket = $this->getPocketImportService();
66 83
67 $markAsRead = $this->get('session')->get('mark_as_read'); 84 $markAsRead = $this->get('session')->get('mark_as_read');
68 $this->get('session')->remove('mark_as_read'); 85 $this->get('session')->remove('mark_as_read');