+
+ private function assignTagsToEntry(Entry $entry, $tags)
+ {
+ foreach ($tags as $tag) {
+ $label = trim($tag);
+ $tagEntity = $this->em
+ ->getRepository('WallabagCoreBundle:Tag')
+ ->findOneByLabel($label);
+ if (is_object($tagEntity)) {
+ $entry->addTag($tagEntity);
+ } else {
+ $newTag = new Tag();
+ $newTag->setLabel($label);
+ $entry->addTag($newTag);
+ }
+ $this->em->flush();
+ }
+ }