Last active
August 29, 2015 13:58
-
-
Save jpetitcolas/10367887 to your computer and use it in GitHub Desktop.
Issue with Document Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Controller | |
$tag = new Tag(); | |
$dm->persist($tag); | |
$dm->flush(); | |
$this->getContainer()->get('my_service')->import($content, $tag); | |
// Service | |
public function import(Content $content, Tag $tag) | |
{ | |
// With following line, it works. | |
$tag = $this->contentRepository->getDocumentManager()->find(null, $tag->getId()); | |
// Otherwise: | |
// A detached document was found through a reference during cascading a persist operation: my-tag (tag-id) | |
$content->addTag($tag); | |
$this->contentRepository->getDocumentManager()->flush(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment