wallabag/src/Wallabag/ImportBundle/Controller/PocketController.php

44 lines
1.1 KiB
PHP
Raw Normal View History

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
{
/**
* @Route("/import/pocket", name="pocket_import")
2015-10-20 11:58:13 +00:00
*/
public function indexAction()
2015-10-20 11:58:13 +00:00
{
return $this->render('WallabagImportBundle:Pocket:index.html.twig', array());
}
/**
* @Route("/import/pocket/auth", name="pocket_auth")
2015-10-20 11:58:13 +00:00
*/
public function authAction()
{
$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
}
/**
* @Route("/import/pocket/callback", name="pocket_callback")
2015-10-20 11:58:13 +00:00
*/
public function callbackAction()
{
$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'));
}
}