Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- oneToMany:
- tagPostAssociations:
- targetEntity: MockizartBundleBlogBundleEntityMockblogTagPost
- mappedBy: "post"
- cascade: ["persist","remove"]
- oneToMany:
- tagPostAssociations:
- targetEntity: MockizartBundleBlogBundleEntityMockblogTagPost
- mappedBy: "tag"
- cascade: ["persist","remove"]
- manyToOne:
- post:
- associationKey: true
- targetEntity: MockizartBundleBlogBundleEntityMockblogPost
- inversedBy: "tagPostAssociations"
- tag:
- targetEntity: MockizartBundleBlogBundleEntityMockblogTag
- inversedBy: "tagPostAssociations"
- $post = $this->getDoctrine()->getManager()->find('MockizartBlogBundle:MockblogPost',6);
- $b = $this->getDoctrine()->getManager()->find('MockizartBlogBundle:MockblogTagPost',['tagId' => 20,'postId' => 6]);
- $post->removeTagPostAssociation($b);
- $this->getDoctrine()->getManager()->persist($post);
- $this->getDoctrine()->getManager()->flush();
- public function __construct($tag, $post)
- {
- $this->tagId = $tag->getId();
- $this->postId = $post->getId();
- $this->post = $post;
- $this->tag = $tag;
- }
- public $tagPostAssociations;
- public function __construct() {
- $this->tagPostAssociations = new ArrayCollection();
- }
- public function addTagPostAssociation(MockblogTagPost $tagPostAssociations)
- {
- $newTag = $tagPostAssociations;
- $this->newTags[$newTag->getTagId().$newTag->getPostId()] = $newTag;
- $hasTagPost = $this->hasTagPost($newTag);
- if (!$hasTagPost) {
- $this->tagPostAssociations[] = $tagPostAssociations;
- }
- return $this;
- }
- public function removeTagPostAssociation(MockblogTagPost $tagPost)
- {
- $this->tagPostAssociations->removeElement($tagPost);
- return $this;
- }
- public function getTagPostAssociations()
- {
- return $this->tagPostAssociations;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement