forked from wallabag/wallabag
@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
@ -24,12 +25,12 @@ class PocketImport implements ImportInterface
|
||||
private $importedEntries = 0;
|
||||
protected $accessToken;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@ -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" ]]
|
||||
|
||||
@ -5,6 +5,12 @@
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div class="card-panel settings">
|
||||
{% if not has_consumer_key %}
|
||||
<div class="card-panel red darken-1">
|
||||
{% trans %}Pocket import isn't configured. You need to define pocket_consumer_key.{% endtrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<blockquote>{{ import.description|trans }}</blockquote>
|
||||
<p>{% 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 %}</p>
|
||||
<form method="post" action="{{ path('import_pocket_auth') }}">
|
||||
|
||||
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user