]>
Commit | Line | Data |
---|---|---|
1f4408de NL |
1 | <?php |
2 | ||
3 | namespace Wallabag\ImportBundle\Controller; | |
4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |
ff7b031d | 7 | use Wallabag\ImportBundle\Import\PocketImport; |
1f4408de NL |
8 | |
9 | class PocketController extends Controller | |
10 | { | |
11 | /** | |
12 | * @Route("/import", name="import") | |
13 | */ | |
14 | public function importAction() | |
15 | { | |
16 | return $this->render('WallabagImportBundle:Pocket:index.html.twig', array()); | |
17 | } | |
18 | ||
1f4408de NL |
19 | /** |
20 | * @Route("/auth-pocket", name="authpocket") | |
21 | */ | |
22 | public function authAction() | |
23 | { | |
ff7b031d NL |
24 | $pocket = new PocketImport($this->get('security.token_storage'), $this->get('session'), $this->getDoctrine()->getManager(), $this->container->getParameter('pocket_consumer_key')); |
25 | $authUrl = $pocket->oAuthRequest($this->generateUrl('import', array(), true), $this->generateUrl('callbackpocket', array(), true)); | |
1f4408de | 26 | |
ff7b031d | 27 | return $this->redirect($authUrl, 301); |
1f4408de NL |
28 | } |
29 | ||
30 | /** | |
31 | * @Route("/callback-pocket", name="callbackpocket") | |
32 | */ | |
33 | public function callbackAction() | |
34 | { | |
ff7b031d NL |
35 | $pocket = new PocketImport($this->get('security.token_storage'), $this->get('session'), $this->getDoctrine()->getManager(), $this->container->getParameter('pocket_consumer_key')); |
36 | $accessToken = $pocket->oAuthAuthorize(); | |
37 | $pocket->import($accessToken); | |
1f4408de NL |
38 | |
39 | return $this->redirect($this->generateUrl('homepage')); | |
40 | } | |
1f4408de | 41 | } |