if ($form->isValid()) {
$existingEntry = $em
->getRepository('WallabagCoreBundle:Entry')
- ->findOneByUrl($entry->getUrl());
+ ->findOneByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
- if (!is_null($existingEntry)) {
+ if (count($existingEntry) > 0) {
$this->get('session')->getFlashBag()->add(
'notice',
- 'Entry already saved on '.$existingEntry->getCreatedAt()->format('d-m-Y')
+ 'Entry already saved on '.$existingEntry[0]->getCreatedAt()->format('d-m-Y')
);
- return $this->redirect($this->generateUrl('view', array('id' => $existingEntry->getId())));
+ return $this->redirect($this->generateUrl('view', array('id' => $existingEntry[0]->getId())));
}
$this->updateEntry($entry);
namespace Wallabag\ImportBundle\DependencyInjection;
-use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('wallabag_import');
- $rootNode
- ->children()
- ->arrayNode('importers')
- ->append($this->getURLs())
- ->end()
- ->end()
- ;
-
return $treeBuilder;
}
-
- private function getURLs()
- {
- $node = new ArrayNodeDefinition('pocket_urls');
- $node->prototype('scalar')->end();
-
- return $node;
- }
}
private $session;
private $em;
private $consumerKey;
- private $skippedEntries;
- private $importedEntries;
- private $pocketURL;
+ private $skippedEntries = 0;
+ private $importedEntries = 0;
- public function __construct($tokenStorage, Session $session, EntityManager $em, $consumerKey, $pocketURL)
+ public function __construct($tokenStorage, Session $session, EntityManager $em, $consumerKey)
{
$this->user = $tokenStorage->getToken()->getUser();
$this->session = $session;
$this->em = $em;
$this->consumerKey = $consumerKey;
- $this->skippedEntries = 0;
- $this->importedEntries = 0;
- $this->pocketURL = $pocketURL;
}
public function getName()
$existingEntry = $this->em
->getRepository('WallabagCoreBundle:Entry')
- ->findOneByUrl($url);
+ ->findOneByUrlAndUserId($url, $this->user->getId());
- if (!is_null($existingEntry)) {
+ if (count($existingEntry) > 0) {
++$this->skippedEntries;
continue;
}
}
if (!empty($pocketEntry['tags'])) {
- // $this->assignTagsToEntry($entry, $pocketEntry['tags']);
+ $this->assignTagsToEntry($entry, $pocketEntry['tags']);
}
$this->em->persist($entry);
public function oAuthRequest($redirectUri, $callbackUri)
{
$client = $this->createClient();
- $request = $client->createRequest('POST', $this->pocketURL['oauth_request'],
+ $request = $client->createRequest('POST', 'https://getpocket.com/v3/oauth/request',
[
'body' => json_encode([
'consumer_key' => $this->consumerKey,
// store code in session for callback method
$this->session->set('pocketCode', $values['code']);
- return $this->pocketURL['auth_authorize'].'?request_token='.$values['code'].'&redirect_uri='.$callbackUri;
+ return 'https://getpocket.com/auth/authorize?request_token='.$values['code'].'&redirect_uri='.$callbackUri;
}
public function oAuthAuthorize()
{
$client = $this->createClient();
- $request = $client->createRequest('POST', $this->pocketURL['oauth_authorize'],
+ $request = $client->createRequest('POST', 'https://getpocket.com/v3/oauth/authorize',
[
'body' => json_encode([
'consumer_key' => $this->consumerKey,
{
$client = $this->createClient();
- $request = $client->createRequest('POST', $this->pocketURL['get'],
+ $request = $client->createRequest('POST', 'https://getpocket.com/v3/get',
[
'body' => json_encode([
'consumer_key' => $this->consumerKey,