Advertisement
Guest User

Untitled

a guest
May 27th, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. // ContentTrait.php
  2.  
  3. <?php
  4.  
  5. namespace Example\FrontendBundle\Document;
  6.  
  7. use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;
  8.  
  9. trait ContentTrait {
  10.  
  11. /**
  12. * @PHPCR\Id()
  13. */
  14. protected $id;
  15.  
  16. /**
  17. * @PHPCR\ParentDocument()
  18. */
  19. protected $parent;
  20.  
  21. /**
  22. * The language this document currently is in
  23. * @PHPCR\Locale
  24. */
  25. protected $locale;
  26.  
  27. /**
  28. * @PHPCR\Nodename()
  29. */
  30. protected $nodename;
  31.  
  32.  
  33. /**
  34. * @PHPCR\Date()
  35. */
  36. protected $date;
  37.  
  38.  
  39. /**
  40. * @PHPCR\Referrers(
  41. * referringDocument="Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route",
  42. * referencedBy="content"
  43. * )
  44. */
  45. protected $routes;
  46.  
  47.  
  48. // Getters and Setters here
  49.  
  50. }
  51.  
  52.  
  53. // Page.php
  54.  
  55. <?php
  56.  
  57. namespace Example\FrontendBundle\Document;
  58.  
  59. use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;
  60. use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface;
  61.  
  62. /**
  63. * @PHPCR\Document(referenceable=true, translator="attribute")
  64. */
  65. class Page implements RouteReferrersReadInterface
  66. {
  67.  
  68. use ContentTrait;
  69.  
  70. /**
  71. * @PHPCR\String(nullable=true, translated=true)
  72. */
  73. protected $title;
  74.  
  75. /**
  76. * @PHPCR\String(nullable=true, translated=true)
  77. */
  78. protected $content;
  79.  
  80. // Getters and Setters here
  81. }
  82.  
  83.  
  84. // Controller.php
  85. // in create Action
  86.  
  87. $rootNode = $dm->find(null, $this->root_path);
  88. $document->setParentDocument($rootNode);
  89. $dm->persist($document);
  90. $dm->flush();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement