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-12-24 14:22:56 +00:00
|
|
|
* @Route("/import/pocket", name="pocket_import")
|
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-12-24 14:22:56 +00:00
|
|
|
* @Route("/import/pocket/auth", name="pocket_auth")
|
2015-10-20 11:58:13 +00:00
|
|
|
*/
|
|
|
|
public function authAction()
|
|
|
|
{
|
2015-12-24 14:22:56 +00:00
|
|
|
$pocket = $this->get('wallabag_import.pocket.import');
|
|
|
|
$authUrl = $pocket->oAuthRequest(
|
|
|
|
$this->generateUrl('import', array(), true),
|
|
|
|
$this->generateUrl('pocket_callback', 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-12-24 14:22:56 +00:00
|
|
|
* @Route("/import/pocket/callback", name="pocket_callback")
|
2015-10-20 11:58:13 +00:00
|
|
|
*/
|
|
|
|
public function callbackAction()
|
|
|
|
{
|
2015-12-24 14:22:56 +00:00
|
|
|
$pocket = $this->get('wallabag_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'));
|
|
|
|
}
|
|
|
|
}
|