diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-02-19 21:21:47 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-02-19 21:21:47 +0100 |
commit | 0cde91cc6f42497844866d7631b8f28e024af965 (patch) | |
tree | 3cca40042f576a67672bde1236bd059b710f4f97 /src/Wallabag/ImportBundle/Import/PocketImport.php | |
parent | a8c6b8ee0cb4e77731df502a05479a8501806309 (diff) | |
parent | c2656f96d4776c86b13d8a4c93a78ee7c4d3824c (diff) | |
download | wallabag-0cde91cc6f42497844866d7631b8f28e024af965.tar.gz wallabag-0cde91cc6f42497844866d7631b8f28e024af965.tar.zst wallabag-0cde91cc6f42497844866d7631b8f28e024af965.zip |
Merge pull request #1699 from wallabag/v2-assign-tag
Move assignTagsToEntry in ContentProxy helper
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/PocketImport.php')
-rw-r--r-- | src/Wallabag/ImportBundle/Import/PocketImport.php | 26 |
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; | |||
9 | use GuzzleHttp\Exception\RequestException; | 9 | use GuzzleHttp\Exception\RequestException; |
10 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | 10 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
11 | use Wallabag\CoreBundle\Entity\Entry; | 11 | use Wallabag\CoreBundle\Entity\Entry; |
12 | use Wallabag\CoreBundle\Entity\Tag; | ||
13 | use Wallabag\CoreBundle\Helper\ContentProxy; | 12 | use Wallabag\CoreBundle\Helper\ContentProxy; |
14 | use Craue\ConfigBundle\Util\Config; | 13 | use 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); |