/** * {@inheritdoc} */ public function guessValues(UrlInformation $urlInformation, $object, $sitemap) { if (null !== $urlInformation->getDepth()) { return; } $manager = $this->managerRegistry->getManagerForClass(ClassUtils::getRealClass(get_class($object))); if (!$manager instanceof DocumentManager) { return; } $node = $manager->getNodeForDocument($object); if (null === $node) { return; } $urlInformation->setDepth($node->getDepth() - $this->offset); }
/** * {@inheritDoc} */ public function init(ManagerRegistry $registry) { /** @var $dm DocumentManager */ $dm = $registry->getManagerForClass('Symfony\\Cmf\\Bundle\\SimpleCmsBundle\\Doctrine\\Phpcr\\Page'); if ($dm->find(null, $this->basePath)) { return; } $session = $dm->getPhpcrSession(); NodeHelper::createPath($session, PathHelper::getParentPath($this->basePath)); $page = new $this->documentClass(); $page->setId($this->basePath); $page->setLabel('Home'); $page->setTitle('Homepage'); $page->setBody('Autocreated Homepage'); $dm->persist($page); $dm->flush(); }
/** * {@inheritdoc} */ public function init(ManagerRegistry $registry) { /** @var $dm DocumentManager */ $dm = $registry->getManagerForClass('AppBundle\\Document\\SeoPage'); if ($dm->find(null, $this->basePath)) { return; } $session = $dm->getPhpcrSession(); NodeHelper::createPath($session, PathHelper::getParentPath($this->basePath)); /** @var \AppBundle\Document\SeoPage $page */ $page = new $this->documentClass(); $page->setId($this->basePath); $page->setLabel('Home'); $page->setTitle('Homepage'); $page->setBody('Autocreated Homepage'); $page->setIsVisibleForSitemap(true); $dm->persist($page); $dm->flush(); }
/** * This method should be used to establish the requisite * structure needed by the application or bundle of the * content repository. * * @param ManagerRegistry $registry */ public function init(ManagerRegistry $registry) { $className = self::MENU_DOCUMENT_CLASS_NAME; /** @var DocumentManager $dm */ $dm = $registry->getManagerForClass($className); /** @var Generic $parent */ $menuRoot = $this->menuProvider->getMenuRoot(); $parent = $dm->find(null, $menuRoot); if (!$parent) { throw new \InvalidArgumentException("Cannot find menu base path '{$this->menuProvider}'."); } foreach ($this->menus as $menuName => $menuLabel) { /** @var Menu $menu */ $menu = $dm->find($className, $menuRoot . '/' . $menuName); if (!$menu) { $menu = new $className(); } $menu->setName($menuName); $menu->setLabel($menuLabel); $menu->setParentDocument($parent); $dm->persist($menu); } $dm->flush(); }