mirror of
https://github.com/wallabag/wallabag.git
synced 2025-02-20 12:36:18 +00:00
Update url & service name
Prefix ur with service namel: [service]_[route name] Add comment in Interface
This commit is contained in:
parent
5a4bbcc9a7
commit
0aa344dc24
6 changed files with 56 additions and 13 deletions
|
@ -8,7 +8,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
class PocketController extends Controller
|
class PocketController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route("/import/pocket", name="pocket")
|
* @Route("/import/pocket", name="pocket_import")
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
|
@ -16,22 +16,25 @@ class PocketController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/import/pocket/auth", name="authpocket")
|
* @Route("/import/pocket/auth", name="pocket_auth")
|
||||||
*/
|
*/
|
||||||
public function authAction()
|
public function authAction()
|
||||||
{
|
{
|
||||||
$pocket = $this->get('wallabag_import.import.pocket_import');
|
$pocket = $this->get('wallabag_import.pocket.import');
|
||||||
$authUrl = $pocket->oAuthRequest($this->generateUrl('import', array(), true), $this->generateUrl('callbackpocket', array(), true));
|
$authUrl = $pocket->oAuthRequest(
|
||||||
|
$this->generateUrl('import', array(), true),
|
||||||
|
$this->generateUrl('pocket_callback', array(), true)
|
||||||
|
);
|
||||||
|
|
||||||
return $this->redirect($authUrl, 301);
|
return $this->redirect($authUrl, 301);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/import/pocket/callback", name="callbackpocket")
|
* @Route("/import/pocket/callback", name="pocket_callback")
|
||||||
*/
|
*/
|
||||||
public function callbackAction()
|
public function callbackAction()
|
||||||
{
|
{
|
||||||
$pocket = $this->get('wallabag_import.import.pocket_import');
|
$pocket = $this->get('wallabag_import.pocket.import');
|
||||||
$accessToken = $pocket->oAuthAuthorize();
|
$accessToken = $pocket->oAuthAuthorize();
|
||||||
$pocket->import($accessToken);
|
$pocket->import($accessToken);
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,42 @@ namespace Wallabag\ImportBundle\Import;
|
||||||
|
|
||||||
interface ImportInterface
|
interface ImportInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Name of the import.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getName();
|
public function getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the import.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getDescription();
|
public function getDescription();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the oauth url to authenticate the client.
|
||||||
|
*
|
||||||
|
* @param string $redirectUri Redirect url in case of error
|
||||||
|
* @param string $callbackUri Url when the authentication is complete
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function oAuthRequest($redirectUri, $callbackUri);
|
public function oAuthRequest($redirectUri, $callbackUri);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Usually called by the previous callback to authorize the client.
|
||||||
|
* Then it return a token that can be used for next requests.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function oAuthAuthorize();
|
public function oAuthAuthorize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import content using the user token.
|
||||||
|
*
|
||||||
|
* @param string $accessToken User access token
|
||||||
|
*/
|
||||||
public function import($accessToken);
|
public function import($accessToken);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace Wallabag\ImportBundle\Import;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Wallabag\CoreBundle\Entity\Entry;
|
use Wallabag\CoreBundle\Entity\Entry;
|
||||||
use Wallabag\CoreBundle\Entity\Tag;
|
use Wallabag\CoreBundle\Entity\Tag;
|
||||||
use Wallabag\CoreBundle\Tools\Utils;
|
use Wallabag\CoreBundle\Tools\Utils;
|
||||||
|
@ -18,7 +19,7 @@ class PocketImport implements ImportInterface
|
||||||
private $skippedEntries = 0;
|
private $skippedEntries = 0;
|
||||||
private $importedEntries = 0;
|
private $importedEntries = 0;
|
||||||
|
|
||||||
public function __construct($tokenStorage, Session $session, EntityManager $em, $consumerKey)
|
public function __construct(TokenStorageInterface $tokenStorage, Session $session, EntityManager $em, $consumerKey)
|
||||||
{
|
{
|
||||||
$this->user = $tokenStorage->getToken()->getUser();
|
$this->user = $tokenStorage->getToken()->getUser();
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
|
@ -26,11 +27,17 @@ class PocketImport implements ImportInterface
|
||||||
$this->consumerKey = $consumerKey;
|
$this->consumerKey = $consumerKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return 'Pocket';
|
return 'Pocket';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function getDescription()
|
public function getDescription()
|
||||||
{
|
{
|
||||||
return 'This importer will import all your <a href="https://getpocket.com">Pocket</a> data.';
|
return 'This importer will import all your <a href="https://getpocket.com">Pocket</a> data.';
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
services:
|
services:
|
||||||
wallabag_import.import.pocket_import:
|
wallabag_import.pocket.import:
|
||||||
class: Wallabag\ImportBundle\Import\PocketImport
|
class: Wallabag\ImportBundle\Import\PocketImport
|
||||||
arguments:
|
arguments:
|
||||||
- @security.token_storage
|
- "@security.token_storage"
|
||||||
- @session
|
- "@session"
|
||||||
- @doctrine.orm.entity_manager
|
- "@doctrine.orm.entity_manager"
|
||||||
- %pocket_consumer_key%
|
- %pocket_consumer_key%
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<div class="card-panel settings">
|
<div class="card-panel settings">
|
||||||
{% trans %}Welcome on wallabag importer. Please select your previous service that you want to migrate.{% endtrans %}
|
{% trans %}Welcome on wallabag importer. Please select your previous service that you want to migrate.{% endtrans %}
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="{{ path('pocket') }}">Pocket</a></li>
|
<li><a href="{{ path('pocket_import') }}">Pocket</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<div class="card-panel settings">
|
<div class="card-panel settings">
|
||||||
{% trans %}You can import your data from your Pocket account. You just have to click on the below button and authorize the application to connect to getpocket.com.{% endtrans %}
|
{% trans %}You can import your data from your Pocket account. You just have to click on the below button and authorize the application to connect to getpocket.com.{% endtrans %}
|
||||||
<form method="post" action="{{ path('authpocket') }}">
|
<form method="post" action="{{ path('pocket_auth') }}">
|
||||||
<input type="submit" value="Connect to Pocket and import data" />
|
<input type="submit" value="Connect to Pocket and import data" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue