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;
|
2015-10-23 12:01:27 +00:00
|
|
|
use Wallabag\ImportBundle\Import\PocketImport;
|
2015-10-20 11:58:13 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Route("/callback-pocket", name="callbackpocket")
|
|
|
|
*/
|
|
|
|
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'));
|
|
|
|
}
|
|
|
|
}
|