public function load(ObjectManager $dm) { if (!$dm instanceof DocumentManager) { $class = get_class($dm); throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '{$class}' given."); } $parent = $dm->find(null, '/cms/pages'); $rootPage = new Page(); $rootPage->setTitle('main'); $rootPage->setParentDocument($parent); $dm->persist($rootPage); $page = new Page(); $page->setTitle('Home'); $page->setParentDocument($rootPage); $page->setContent(<<<HERE Welcome to the homepage of this really basic CMS. HERE ); $dm->persist($page); $page = new Page(); $page->setTitle('About'); $page->setParentDocument($rootPage); $page->setContent(<<<HERE This page explains what its all about. HERE ); $dm->persist($page); $dm->flush(); }
/** * @param \Acme\BasicCmsBundle\Document\Page $document * @return void */ public function prePersist($document) { $slugify = new Slugify(); $document->setSlug($slugify->slugify($document->getTitle())); $parent = $this->getModelManager()->find(null, '/cms/pages'); $document->setParentDocument($parent); }
/** * {@inheritDoc} */ public function setParentDocument($parent) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setParentDocument', array($parent)); return parent::setParentDocument($parent); }