aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Controller/PocketController.php
blob: 9602c2823b621092bbefc6ce8e31402b0bb0cf30 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

namespace Wallabag\ImportBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Wallabag\ImportBundle\Import\PocketImport;

class PocketController extends Controller
{
    /**
     * @Route("/import", name="import")
     */
    public function importAction()
    {
        return $this->render('WallabagImportBundle:Pocket:index.html.twig', array());
    }

    /**
     * @Route("/auth-pocket", name="authpocket")
     */
    public function authAction()
    {
        $pocket = $this->get('wallabag_import.import.pocket_import');
        $authUrl = $pocket->oAuthRequest($this->generateUrl('import', array(), true), $this->generateUrl('callbackpocket', array(), true));

        return $this->redirect($authUrl, 301);
    }

    /**
     * @Route("/callback-pocket", name="callbackpocket")
     */
    public function callbackAction()
    {
        $pocket = $this->get('wallabag_import.import.pocket_import');
        $accessToken = $pocket->oAuthAuthorize();
        $pocket->import($accessToken);

        return $this->redirect($this->generateUrl('homepage'));
    }
}