diff options
Diffstat (limited to 'src/Wallabag/ImportBundle/Import')
-rw-r--r-- | src/Wallabag/ImportBundle/Import/ImportInterface.php | 33 | ||||
-rw-r--r-- | src/Wallabag/ImportBundle/Import/PocketImport.php | 9 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/Wallabag/ImportBundle/Import/ImportInterface.php b/src/Wallabag/ImportBundle/Import/ImportInterface.php index f07a120c..0f9b3256 100644 --- a/src/Wallabag/ImportBundle/Import/ImportInterface.php +++ b/src/Wallabag/ImportBundle/Import/ImportInterface.php | |||
@@ -4,9 +4,42 @@ namespace Wallabag\ImportBundle\Import; | |||
4 | 4 | ||
5 | interface ImportInterface | 5 | interface ImportInterface |
6 | { | 6 | { |
7 | /** | ||
8 | * Name of the import. | ||
9 | * | ||
10 | * @return string | ||
11 | */ | ||
7 | public function getName(); | 12 | public function getName(); |
13 | |||
14 | /** | ||
15 | * Description of the import. | ||
16 | * | ||
17 | * @return string | ||
18 | */ | ||
8 | public function getDescription(); | 19 | public function getDescription(); |
20 | |||
21 | /** | ||
22 | * Return the oauth url to authenticate the client. | ||
23 | * | ||
24 | * @param string $redirectUri Redirect url in case of error | ||
25 | * @param string $callbackUri Url when the authentication is complete | ||
26 | * | ||
27 | * @return string | ||
28 | */ | ||
9 | public function oAuthRequest($redirectUri, $callbackUri); | 29 | public function oAuthRequest($redirectUri, $callbackUri); |
30 | |||
31 | /** | ||
32 | * Usually called by the previous callback to authorize the client. | ||
33 | * Then it return a token that can be used for next requests. | ||
34 | * | ||
35 | * @return string | ||
36 | */ | ||
10 | public function oAuthAuthorize(); | 37 | public function oAuthAuthorize(); |
38 | |||
39 | /** | ||
40 | * Import content using the user token. | ||
41 | * | ||
42 | * @param string $accessToken User access token | ||
43 | */ | ||
11 | public function import($accessToken); | 44 | public function import($accessToken); |
12 | } | 45 | } |
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index ef8f9eb5..85bab0db 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php | |||
@@ -5,6 +5,7 @@ namespace Wallabag\ImportBundle\Import; | |||
5 | use Doctrine\ORM\EntityManager; | 5 | use Doctrine\ORM\EntityManager; |
6 | use GuzzleHttp\Client; | 6 | use GuzzleHttp\Client; |
7 | use Symfony\Component\HttpFoundation\Session\Session; | 7 | use Symfony\Component\HttpFoundation\Session\Session; |
8 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
8 | use Wallabag\CoreBundle\Entity\Entry; | 9 | use Wallabag\CoreBundle\Entity\Entry; |
9 | use Wallabag\CoreBundle\Entity\Tag; | 10 | use Wallabag\CoreBundle\Entity\Tag; |
10 | use Wallabag\CoreBundle\Tools\Utils; | 11 | use Wallabag\CoreBundle\Tools\Utils; |
@@ -18,7 +19,7 @@ class PocketImport implements ImportInterface | |||
18 | private $skippedEntries = 0; | 19 | private $skippedEntries = 0; |
19 | private $importedEntries = 0; | 20 | private $importedEntries = 0; |
20 | 21 | ||
21 | public function __construct($tokenStorage, Session $session, EntityManager $em, $consumerKey) | 22 | public function __construct(TokenStorageInterface $tokenStorage, Session $session, EntityManager $em, $consumerKey) |
22 | { | 23 | { |
23 | $this->user = $tokenStorage->getToken()->getUser(); | 24 | $this->user = $tokenStorage->getToken()->getUser(); |
24 | $this->session = $session; | 25 | $this->session = $session; |
@@ -26,11 +27,17 @@ class PocketImport implements ImportInterface | |||
26 | $this->consumerKey = $consumerKey; | 27 | $this->consumerKey = $consumerKey; |
27 | } | 28 | } |
28 | 29 | ||
30 | /** | ||
31 | * {@inheritdoc} | ||
32 | */ | ||
29 | public function getName() | 33 | public function getName() |
30 | { | 34 | { |
31 | return 'Pocket'; | 35 | return 'Pocket'; |
32 | } | 36 | } |
33 | 37 | ||
38 | /** | ||
39 | * {@inheritdoc} | ||
40 | */ | ||
34 | public function getDescription() | 41 | public function getDescription() |
35 | { | 42 | { |
36 | return 'This importer will import all your <a href="https://getpocket.com">Pocket</a> data.'; | 43 | return 'This importer will import all your <a href="https://getpocket.com">Pocket</a> data.'; |