Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ContentTrait.php
- <?php
- namespace Example\FrontendBundle\Document;
- use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;
- trait ContentTrait {
- /**
- * @PHPCR\Id()
- */
- protected $id;
- /**
- * @PHPCR\ParentDocument()
- */
- protected $parent;
- /**
- * The language this document currently is in
- * @PHPCR\Locale
- */
- protected $locale;
- /**
- * @PHPCR\Nodename()
- */
- protected $nodename;
- /**
- * @PHPCR\Date()
- */
- protected $date;
- /**
- * @PHPCR\Referrers(
- * referringDocument="Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route",
- * referencedBy="content"
- * )
- */
- protected $routes;
- // Getters and Setters here
- }
- // Page.php
- <?php
- namespace Example\FrontendBundle\Document;
- use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;
- use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface;
- /**
- * @PHPCR\Document(referenceable=true, translator="attribute")
- */
- class Page implements RouteReferrersReadInterface
- {
- use ContentTrait;
- /**
- * @PHPCR\String(nullable=true, translated=true)
- */
- protected $title;
- /**
- * @PHPCR\String(nullable=true, translated=true)
- */
- protected $content;
- // Getters and Setters here
- }
- // Controller.php
- // in create Action
- $rootNode = $dm->find(null, $this->root_path);
- $document->setParentDocument($rootNode);
- $dm->persist($document);
- $dm->flush();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement