3 namespace Wallabag\ImportBundle\Controller
;
5 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
6 use Symfony\Component\Routing\Generator\UrlGeneratorInterface
;
7 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
9 class PocketController
extends Controller
12 * @Route("/pocket", name="import_pocket")
14 public function indexAction()
16 return $this->render('WallabagImportBundle:Pocket:index.html.twig', [
17 'import' => $this->get('wallabag_import.pocket.import'),
22 * @Route("/pocket/auth", name="import_pocket_auth")
24 public function authAction()
26 $requestToken = $this->get('wallabag_import.pocket.import')
27 ->getRequestToken($this->generateUrl('import', array(), UrlGeneratorInterface
::ABSOLUTE_URL
));
29 $this->get('session')->set('import.pocket.code', $requestToken);
31 return $this->redirect(
32 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', array(), UrlGeneratorInterface
::ABSOLUTE_URL
),
38 * @Route("/pocket/callback", name="import_pocket_callback")
40 public function callbackAction()
42 $message = 'Import failed, please try again.';
43 $pocket = $this->get('wallabag_import.pocket.import');
45 // something bad happend on pocket side
46 if (false === $pocket->authorize($this->get('session')->get('import.pocket.code'))) {
47 $this->get('session')->getFlashBag()->add(
52 return $this->redirect($this->generateUrl('import_pocket'));
55 if (true === $pocket->import()) {
56 $summary = $pocket->getSummary();
57 $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.';
60 $this->get('session')->getFlashBag()->add(
65 return $this->redirect($this->generateUrl('homepage'));