/** * {@inheritdoc} */ protected function executeAction($context) { $source = $this->getTaggable($context, static::PATH_SOURCE); $destination = $this->getTaggable($context, static::PATH_DESTINATION); $organization = $this->getOrganization($context); $this->tagManager->loadTagging($source, $organization); $tags = $this->tagManager->getTags($source); $this->tagManager->setTags($destination, $tags); $this->tagManager->saveTagging($destination, true, $organization); }
/** * {@inheritdoc} */ protected function onSuccess($entity) { $targetEntity = $entity['target']; /** @var ArrayCollection $tags */ $tags = $entity['tags']; $names = array_map(function ($tag) { return $tag['name']; }, $tags->getValues()); $tags = $this->tagManager->loadOrCreateTags($names); $this->tagManager->setTags($targetEntity, new ArrayCollection($tags)); $this->tagManager->saveTagging($targetEntity); }
/** * Save tags * * @param EntityDataEvent $event */ public function afterMergeEntity(EntityDataEvent $event) { $entityData = $event->getEntityData(); $entityMetadata = $entityData->getMetadata(); if (!$this->isTaggable($entityMetadata)) { return; } $masterEntity = $entityData->getMasterEntity(); $masterTags = $this->tagManager->getTags($masterEntity)->getValues(); $this->tagManager->setTags($masterEntity, ['all' => $masterTags, 'owner' => $masterTags]); $this->tagManager->saveTagging($masterEntity); }
public function loadContactsTags() { $userTagsCount = count($this->tagsUser); $accountTagsCount = count($this->tagsAccount); foreach ($this->contactsRepository as $contact) { $this->tagManager->setTags($contact, new ArrayCollection([$this->tagsUser[rand(0, $userTagsCount - 1)], $this->tagsAccount[rand(0, $accountTagsCount - 1)]])); $this->tagManager->saveTagging($contact, false); } $this->flush($this->em); }
/** * {@inheritdoc} */ public function setValue($entity, FieldMetadata $metadata, $value) { $this->tagManager->setTags($entity, $value); }