1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-12 16:58:37 +00:00
wallabag/src/Wallabag/ImportBundle/Controller/PocketController.php

42 lines
1.4 KiB
PHP
Raw Normal View History

2015-10-20 13:58:13 +02:00
<?php
namespace Wallabag\ImportBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
2015-10-23 14:01:27 +02:00
use Wallabag\ImportBundle\Import\PocketImport;
2015-10-20 13:58:13 +02: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 14:01:27 +02:00
$pocket = new PocketImport($this->get('security.token_storage'), $this->get('session'), $this->getDoctrine()->getManager(), $this->container->getParameter('pocket_consumer_key'));
$authUrl = $pocket->oAuthRequest($this->generateUrl('import', array(), true), $this->generateUrl('callbackpocket', array(), true));
2015-10-20 13:58:13 +02:00
2015-10-23 14:01:27 +02:00
return $this->redirect($authUrl, 301);
2015-10-20 13:58:13 +02:00
}
/**
* @Route("/callback-pocket", name="callbackpocket")
*/
public function callbackAction()
{
2015-10-23 14:01:27 +02:00
$pocket = new PocketImport($this->get('security.token_storage'), $this->get('session'), $this->getDoctrine()->getManager(), $this->container->getParameter('pocket_consumer_key'));
$accessToken = $pocket->oAuthAuthorize();
$pocket->import($accessToken);
2015-10-20 13:58:13 +02:00
return $this->redirect($this->generateUrl('homepage'));
}
}