From 63e40f2d7c4074aff0be587c828eb511a6b7c878 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 21 Jan 2016 08:53:09 +0100 Subject: Add CraueConfig for internal settings --- src/Wallabag/ImportBundle/Import/PocketImport.php | 5 +++-- src/Wallabag/ImportBundle/Resources/config/services.yml | 2 +- src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php | 11 ++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src/Wallabag/ImportBundle') diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 72b9047c..0463a739 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -11,6 +11,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Helper\ContentProxy; +use Craue\ConfigBundle\Util\Config; class PocketImport implements ImportInterface { @@ -25,12 +26,12 @@ class PocketImport implements ImportInterface protected $accessToken; private $translator; - public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, $consumerKey) + public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, Config $craueConfig) { $this->user = $tokenStorage->getToken()->getUser(); $this->em = $em; $this->contentProxy = $contentProxy; - $this->consumerKey = $consumerKey; + $this->consumerKey = $craueConfig->get('pocket_consumer_key'); $this->logger = new NullLogger(); } diff --git a/src/Wallabag/ImportBundle/Resources/config/services.yml b/src/Wallabag/ImportBundle/Resources/config/services.yml index e4dde100..dc536808 100644 --- a/src/Wallabag/ImportBundle/Resources/config/services.yml +++ b/src/Wallabag/ImportBundle/Resources/config/services.yml @@ -17,7 +17,7 @@ services: - "@security.token_storage" - "@doctrine.orm.entity_manager" - "@wallabag_core.content_proxy" - - %pocket_consumer_key% + - "@craue_config" calls: - [ setClient, [ "@wallabag_import.pocket.client" ] ] - [ setLogger, [ "@logger" ]] diff --git a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php index 76225fe4..25359d56 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php @@ -55,11 +55,20 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $config = $this->getMockBuilder('Craue\ConfigBundle\Util\Config') + ->disableOriginalConstructor() + ->getMock(); + + $config->expects($this->any()) + ->method('get') + ->with('pocket_consumer_key') + ->willReturn($consumerKey); + $pocket = new PocketImportMock( $this->tokenStorage, $this->em, $this->contentProxy, - $consumerKey + $config ); $this->logHandler = new TestHandler(); -- cgit v1.2.3 From 1e3ed714707878caa603ffdc262e64abb6ddfb5c Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 21 Jan 2016 10:59:21 +0100 Subject: Add warning message for PocketImport Warn user if pocket_consumer_key isn't defined --- src/Wallabag/ImportBundle/Controller/PocketController.php | 1 + src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'src/Wallabag/ImportBundle') diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php index 7aee302f..1c1b4fa8 100644 --- a/src/Wallabag/ImportBundle/Controller/PocketController.php +++ b/src/Wallabag/ImportBundle/Controller/PocketController.php @@ -15,6 +15,7 @@ class PocketController extends Controller { return $this->render('WallabagImportBundle:Pocket:index.html.twig', [ 'import' => $this->get('wallabag_import.pocket.import'), + 'has_consumer_key' => '' == trim($this->get('craue_config')->get('pocket_consumer_key')) ? false : true, ]); } diff --git a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig index 643ad775..e0e36f38 100644 --- a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig +++ b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig @@ -5,6 +5,12 @@
+ {% if not has_consumer_key %} +
+ {% trans %}Pocket import isn't configured. You need to define pocket_consumer_key.{% endtrans %} +
+ {% endif %} +
{{ import.description|trans }}

{% 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 %}

-- cgit v1.2.3