3 namespace Wallabag\ImportBundle\Controller
;
5 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
6 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
8 class PocketController
extends Controller
11 * @Route("/pocket", name="import_pocket")
13 public function indexAction()
15 return $this->render('WallabagImportBundle:Pocket:index.html.twig', [
16 'import' => $this->get('wallabag_import.pocket.import'),
21 * @Route("/pocket/auth", name="import_pocket_auth")
23 public function authAction()
25 $requestToken = $this->get('wallabag_import.pocket.import')
26 ->getRequestToken($this->generateUrl('import', [], true));
28 $this->get('session')->set('import.pocket.code', $requestToken);
30 return $this->redirect(
31 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', [], true),
37 * @Route("/pocket/callback", name="import_pocket_callback")
39 public function callbackAction()
41 $message = 'Import failed, please try again.';
42 $pocket = $this->get('wallabag_import.pocket.import');
44 // something bad happend on pocket side
45 if (false === $pocket->authorize($this->get('session')->get('import.pocket.code'))) {
46 $this->get('session')->getFlashBag()->add(
51 return $this->redirect($this->generateUrl('import_pocket'));
54 if (true === $pocket->import()) {
55 $summary = $pocket->getSummary();
56 $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.';
59 $this->get('session')->getFlashBag()->add(
64 return $this->redirect($this->generateUrl('homepage'));