Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. oneToMany:
  2. tagPostAssociations:
  3. targetEntity: MockizartBundleBlogBundleEntityMockblogTagPost
  4. mappedBy: "post"
  5. cascade: ["persist","remove"]
  6.  
  7. oneToMany:
  8. tagPostAssociations:
  9. targetEntity: MockizartBundleBlogBundleEntityMockblogTagPost
  10. mappedBy: "tag"
  11. cascade: ["persist","remove"]
  12.  
  13. manyToOne:
  14. post:
  15. associationKey: true
  16. targetEntity: MockizartBundleBlogBundleEntityMockblogPost
  17. inversedBy: "tagPostAssociations"
  18. tag:
  19. targetEntity: MockizartBundleBlogBundleEntityMockblogTag
  20. inversedBy: "tagPostAssociations"
  21.  
  22. $post = $this->getDoctrine()->getManager()->find('MockizartBlogBundle:MockblogPost',6);
  23. $b = $this->getDoctrine()->getManager()->find('MockizartBlogBundle:MockblogTagPost',['tagId' => 20,'postId' => 6]);
  24. $post->removeTagPostAssociation($b);
  25. $this->getDoctrine()->getManager()->persist($post);
  26. $this->getDoctrine()->getManager()->flush();
  27.  
  28. public function __construct($tag, $post)
  29. {
  30. $this->tagId = $tag->getId();
  31. $this->postId = $post->getId();
  32. $this->post = $post;
  33. $this->tag = $tag;
  34. }
  35.  
  36. public $tagPostAssociations;
  37.  
  38. public function __construct() {
  39. $this->tagPostAssociations = new ArrayCollection();
  40. }
  41.  
  42. public function addTagPostAssociation(MockblogTagPost $tagPostAssociations)
  43. {
  44. $newTag = $tagPostAssociations;
  45. $this->newTags[$newTag->getTagId().$newTag->getPostId()] = $newTag;
  46. $hasTagPost = $this->hasTagPost($newTag);
  47.  
  48. if (!$hasTagPost) {
  49. $this->tagPostAssociations[] = $tagPostAssociations;
  50. }
  51.  
  52. return $this;
  53. }
  54.  
  55.  
  56. public function removeTagPostAssociation(MockblogTagPost $tagPost)
  57. {
  58. $this->tagPostAssociations->removeElement($tagPost);
  59.  
  60.  
  61. return $this;
  62. }
  63.  
  64. public function getTagPostAssociations()
  65. {
  66. return $this->tagPostAssociations;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement