aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/PocketImport.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-02-19 14:22:20 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-02-19 14:22:20 +0100
commitc2656f96d4776c86b13d8a4c93a78ee7c4d3824c (patch)
treee7aaddb8e35197420db96bb067fe410e40c0025c /src/Wallabag/ImportBundle/Import/PocketImport.php
parentfa64d861105bd0713acd7ac5d116353273524b4f (diff)
downloadwallabag-c2656f96d4776c86b13d8a4c93a78ee7c4d3824c.tar.gz
wallabag-c2656f96d4776c86b13d8a4c93a78ee7c4d3824c.tar.zst
wallabag-c2656f96d4776c86b13d8a4c93a78ee7c4d3824c.zip
Move assignTagsToEntry in ContentProxy helper
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/PocketImport.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index 22932238..5dfd098c 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -9,7 +9,6 @@ use GuzzleHttp\Client;
9use GuzzleHttp\Exception\RequestException; 9use GuzzleHttp\Exception\RequestException;
10use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 10use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
11use Wallabag\CoreBundle\Entity\Entry; 11use Wallabag\CoreBundle\Entity\Entry;
12use Wallabag\CoreBundle\Entity\Tag;
13use Wallabag\CoreBundle\Helper\ContentProxy; 12use Wallabag\CoreBundle\Helper\ContentProxy;
14use Craue\ConfigBundle\Util\Config; 13use Craue\ConfigBundle\Util\Config;
15 14
@@ -177,26 +176,6 @@ class PocketImport implements ImportInterface
177 $this->client = $client; 176 $this->client = $client;
178 } 177 }
179 178
180 private function assignTagsToEntry(Entry $entry, $tags)
181 {
182 foreach ($tags as $tag) {
183 $label = trim($tag['tag']);
184 $tagEntity = $this->em
185 ->getRepository('WallabagCoreBundle:Tag')
186 ->findOneByLabel($label);
187
188 if (is_object($tagEntity)) {
189 $entry->addTag($tagEntity);
190 } else {
191 $newTag = new Tag();
192 $newTag->setLabel($label);
193
194 $entry->addTag($newTag);
195 }
196 $this->em->flush();
197 }
198 }
199
200 /** 179 /**
201 * @see https://getpocket.com/developer/docs/v3/retrieve 180 * @see https://getpocket.com/developer/docs/v3/retrieve
202 * 181 *
@@ -246,7 +225,10 @@ class PocketImport implements ImportInterface
246 } 225 }
247 226
248 if (isset($pocketEntry['tags']) && !empty($pocketEntry['tags'])) { 227 if (isset($pocketEntry['tags']) && !empty($pocketEntry['tags'])) {
249 $this->assignTagsToEntry($entry, $pocketEntry['tags']); 228 $this->contentProxy->assignTagsToEntry(
229 $entry,
230 array_keys($pocketEntry['tags'])
231 );
250 } 232 }
251 233
252 $this->em->persist($entry); 234 $this->em->persist($entry);