- /**
- * @param Entry $entry
- * @param string $tags
- */
- private function assignTagsToEntry(Entry $entry, $tags)
- {
- foreach (explode(',', $tags) as $label) {
- $label = trim($label);
- $tagEntity = $this
- ->getDoctrine()
- ->getRepository('WallabagCoreBundle:Tag')
- ->findOneByLabel($label);
-
- if (is_null($tagEntity)) {
- $tagEntity = new Tag();
- $tagEntity->setLabel($label);
- }
-
- // only add the tag on the entry if the relation doesn't exist
- if (!$entry->getTags()->contains($tagEntity)) {
- $entry->addTag($tagEntity);
- }
- }
- }
-