2015-10-20 11:58:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Wallabag\ImportBundle\Controller;
|
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|
|
|
|
|
|
|
class PocketController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
2015-10-23 12:45:50 +00:00
|
|
|
* @Route("/import/pocket", name="pocket")
|
2015-10-20 11:58:13 +00:00
|
|
|
*/
|
2015-10-23 12:45:50 +00:00
|
|
|
public function indexAction()
|
2015-10-20 11:58:13 +00:00
|
|
|
{
|
|
|
|
return $this->render('WallabagImportBundle:Pocket:index.html.twig', array());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-23 12:45:50 +00:00
|
|
|
* @Route("/import/pocket/auth", name="authpocket")
|
2015-10-20 11:58:13 +00:00
|
|
|
*/
|
|
|
|
public function authAction()
|
|
|
|
{
|
2015-10-23 12:09:19 +00:00
|
|
|
$pocket = $this->get('wallabag_import.import.pocket_import');
|
2015-10-23 12:01:27 +00:00
|
|
|
$authUrl = $pocket->oAuthRequest($this->generateUrl('import', array(), true), $this->generateUrl('callbackpocket', array(), true));
|
2015-10-20 11:58:13 +00:00
|
|
|
|
2015-10-23 12:01:27 +00:00
|
|
|
return $this->redirect($authUrl, 301);
|
2015-10-20 11:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-23 12:45:50 +00:00
|
|
|
* @Route("/import/pocket/callback", name="callbackpocket")
|
2015-10-20 11:58:13 +00:00
|
|
|
*/
|
|
|
|
public function callbackAction()
|
|
|
|
{
|
2015-10-23 12:09:19 +00:00
|
|
|
$pocket = $this->get('wallabag_import.import.pocket_import');
|
2015-10-23 12:01:27 +00:00
|
|
|
$accessToken = $pocket->oAuthAuthorize();
|
|
|
|
$pocket->import($accessToken);
|
2015-10-20 11:58:13 +00:00
|
|
|
|
|
|
|
return $this->redirect($this->generateUrl('homepage'));
|
|
|
|
}
|
|
|
|
}
|