]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Update url & service name
authorJeremy Benoist <jeremy.benoist@gmail.com>
Thu, 24 Dec 2015 14:22:56 +0000 (15:22 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 2 Jan 2016 22:27:41 +0000 (23:27 +0100)
Prefix ur with service namel: [service]_[route name]
Add comment in Interface

src/Wallabag/ImportBundle/Controller/PocketController.php
src/Wallabag/ImportBundle/Import/ImportInterface.php
src/Wallabag/ImportBundle/Import/PocketImport.php
src/Wallabag/ImportBundle/Resources/config/services.yml
src/Wallabag/ImportBundle/Resources/views/Import/index.html.twig
src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig

index f851c81cf105225abf4fd3fe9f02a56ee721ba43..2ab062e70c151ae685effd1ceb35ae2c3aed32f4 100644 (file)
@@ -8,7 +8,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 class PocketController extends Controller
 {
     /**
-     * @Route("/import/pocket", name="pocket")
+     * @Route("/import/pocket", name="pocket_import")
      */
     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()
     {
-        $pocket = $this->get('wallabag_import.import.pocket_import');
-        $authUrl = $pocket->oAuthRequest($this->generateUrl('import', array(), true), $this->generateUrl('callbackpocket', array(), true));
+        $pocket = $this->get('wallabag_import.pocket.import');
+        $authUrl = $pocket->oAuthRequest(
+            $this->generateUrl('import', array(), true),
+            $this->generateUrl('pocket_callback', array(), true)
+        );
 
         return $this->redirect($authUrl, 301);
     }
 
     /**
-     * @Route("/import/pocket/callback", name="callbackpocket")
+     * @Route("/import/pocket/callback", name="pocket_callback")
      */
     public function callbackAction()
     {
-        $pocket = $this->get('wallabag_import.import.pocket_import');
+        $pocket = $this->get('wallabag_import.pocket.import');
         $accessToken = $pocket->oAuthAuthorize();
         $pocket->import($accessToken);
 
index f07a120cf5cd8b7262e8985f08818c8e470771b1..0f9b3256949b81869eed65d53120afdcf7b43708 100644 (file)
@@ -4,9 +4,42 @@ namespace Wallabag\ImportBundle\Import;
 
 interface ImportInterface
 {
+    /**
+     * Name of the import.
+     *
+     * @return string
+     */
     public function getName();
+
+    /**
+     * Description of the import.
+     *
+     * @return string
+     */
     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);
+
+    /**
+     * 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();
+
+    /**
+     * Import content using the user token.
+     *
+     * @param string $accessToken User access token
+     */
     public function import($accessToken);
 }
index ef8f9eb57bd2ed35542eefa6c73d713330d000ec..85bab0db67084aa4a901dd8ffefd825707d6baaa 100644 (file)
@@ -5,6 +5,7 @@ namespace Wallabag\ImportBundle\Import;
 use Doctrine\ORM\EntityManager;
 use GuzzleHttp\Client;
 use Symfony\Component\HttpFoundation\Session\Session;
+use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
 use Wallabag\CoreBundle\Entity\Entry;
 use Wallabag\CoreBundle\Entity\Tag;
 use Wallabag\CoreBundle\Tools\Utils;
@@ -18,7 +19,7 @@ class PocketImport implements ImportInterface
     private $skippedEntries = 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->session = $session;
@@ -26,11 +27,17 @@ class PocketImport implements ImportInterface
         $this->consumerKey = $consumerKey;
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getName()
     {
         return 'Pocket';
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getDescription()
     {
         return 'This importer will import all your <a href="https://getpocket.com">Pocket</a> data.';
index 82628f082ca42ede9b4c5510b1f428dc5ece04d3..d77779eb1a65883159249866b50da8088078eb17 100644 (file)
@@ -1,8 +1,8 @@
 services:
-    wallabag_import.import.pocket_import:
+    wallabag_import.pocket.import:
         class: Wallabag\ImportBundle\Import\PocketImport
         arguments:
-            - @security.token_storage
-            - @session
-            - @doctrine.orm.entity_manager
+            - "@security.token_storage"
+            - "@session"
+            - "@doctrine.orm.entity_manager"
             - %pocket_consumer_key%
index bdd57e5e37e7b3375000f65ede70f88ebfd982a4..fda21f2da25f05951685d9a1282b79452b3711ef 100644 (file)
@@ -8,7 +8,7 @@
         <div class="card-panel settings">
             {% trans %}Welcome on wallabag importer. Please select your previous service that you want to migrate.{% endtrans %}
             <ul>
-                <li><a href="{{ path('pocket') }}">Pocket</a></li>
+                <li><a href="{{ path('pocket_import') }}">Pocket</a></li>
             </ul>
         </div>
     </div>
index e6abc17b45d662d0c9b82a66d01b5caec64f1060..df64e472c06bd01e5b80ef63f67657889f1f7102 100644 (file)
@@ -7,7 +7,7 @@
     <div class="col s12">
         <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 %}
-            <form method="post" action="{{ path('authpocket') }}">
+            <form method="post" action="{{ path('pocket_auth') }}">
                 <input type="submit" value="Connect to Pocket and import data" />
             </form>
         </div>