public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/test'); $root = $manager->find(null, '/test'); $contentRoot = new Generic; $contentRoot->setNodename('contents'); $contentRoot->setParent($root); $manager->persist($contentRoot); $content = new StaticContent; $content->setName('content-1'); $content->setTitle('Content 1'); $content->setBody('Content 1'); $content->setParentDocument($contentRoot); $manager->persist($content); $content = new StaticContent; $content->setName('content-2'); $content->setTitle('Content 2'); $content->setBody('Content 2'); $content->setParentDocument($contentRoot); $manager->persist($content); $manager->flush(); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $session = $manager->getPhpcrSession(); $basepath = $this->container->getParameter('cmf_routing.dynamic.persistence.phpcr.route_basepath'); NodeHelper::createPath($session, $basepath); $routeRoot = $manager->find(null, $basepath); $basepath = $this->container->getParameter('cmf_content.persistence.phpcr.content_basepath'); NodeHelper::createPath($session, $basepath); $parent = $manager->find(null, $basepath); $repository = $this->container->get('sylius.repository.static_content'); $routeRepository = $this->container->get('sylius.repository.route'); // Terms of service. $route = $routeRepository->createNew(); $route->setPosition($routeRoot, 'terms-of-service'); $manager->persist($route); $content = $repository->createNew(); $content->setTitle('Terms of Service'); $content->setBody($this->faker->text(350)); $content->addRoute($route); $content->setParent($parent); $content->setName('terms-of-service'); $manager->persist($content); // Contact. $route = $routeRepository->createNew(); $route->setPosition($routeRoot, 'about'); $manager->persist($route); $content = $repository->createNew(); $content->setTitle('About us'); $content->setBody($this->faker->text(300)); $content->addRoute($route); $content->setParent($parent); $content->setName('about-us'); $manager->persist($content); $manager->flush(); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $this->manager = $manager; $session = $manager->getPhpcrSession(); //création namespace menu NodeHelper::createPath($session, '/website/symfony-prestacms/route'); $root = $manager->find(null, '/website/symfony-prestacms/route'); //Routing home $configuration = array('parent' => $root, 'content_path' => '/website/symfony-prestacms/page/home', 'name' => 'en', 'locale' => 'en'); $home = $this->getFactory()->create($configuration); $configuration['name'] = 'fr'; $configuration['locale'] = 'fr'; $homeFr = $this->getFactory()->create($configuration); $yaml = new Parser(); $datas = $yaml->parse(file_get_contents(__DIR__ . '/../data/page.yml')); foreach ($datas['pages'] as $pageConfiguration) { if ($pageConfiguration['name'] == 'home') { continue; } $pageConfiguration['content_path'] = '/website/symfony-prestacms/page' . '/' . $pageConfiguration['name']; $pageConfiguration['parent'] = $home; $pageConfiguration['locale'] = 'en'; $this->getFactory()->create($pageConfiguration); $pageConfiguration['parent'] = $homeFr; $pageConfiguration['locale'] = 'fr'; $this->getFactory()->create($pageConfiguration); } $this->manager->flush(); }
public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/test'); NodeHelper::createPath($manager->getPhpcrSession(), '/test/content'); NodeHelper::createPath($manager->getPhpcrSession(), '/test/routes/content'); $contentRoot = $manager->find(null, '/test/content'); $routeRoot = $manager->find(null, '/test/routes/content'); $content = new SeoAwareContent(); $content->setName('content-1'); $content->setTitle('Content 1'); $content->setBody('Content 1'); $content->setParentDocument($contentRoot); $metadata = new SeoMetadata(); $metadata->setTitle('Title content 1'); $metadata->setMetaDescription('Description of content 1.'); $metadata->setMetaKeywords('content1, content'); $metadata->setOriginalUrl('/to/original'); $content->setSeoMetadata($metadata); $manager->persist($content); $route = new Route(); $route->setPosition($routeRoot, 'content-1'); $route->setContent($content); $route->setDefault('_controller', 'Symfony\\Cmf\\Bundle\\SeoBundle\\Tests\\Resources\\Controller\\TestController::indexAction'); $manager->persist($route); $manager->persist($route); $manager->flush(); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $session = $manager->getPhpcrSession(); $basepath = $this->container->getParameter('cmf_block.persistence.phpcr.block_basepath'); NodeHelper::createPath($session, $basepath); $parent = $manager->find(null, $basepath); $factory = $this->container->get('sylius.factory.simple_block'); $contactBlock = $factory->createNew(); $contactBlock->setParentDocument($parent); $contactBlock->setName('contact'); $contactBlock->setTitle('Contact us'); $contactBlock->setBody('<p>Call us ' . $this->faker->phoneNumber . '!</p><p>' . $this->faker->paragraph . '</p>'); $manager->persist($contactBlock); for ($i = 1; $i <= 3; ++$i) { $block = $factory->createNew(); $block->setParentDocument($parent); $block->setName('block-' . $i); $block->setTitle(ucfirst($this->faker->word)); $block->setBody($this->faker->paragraph); $manager->persist($block); } $factory = $this->container->get('sylius.factory.string_block'); $welcomeText = $factory->createNew(); $welcomeText->setParentDocument($parent); $welcomeText->setName('welcome-text'); $welcomeText->setBody('Welcome to Sylius e-commerce'); $manager->persist($welcomeText); $manager->flush(); }
/** * Load data fixtures with the passed DocumentManager * * @param DocumentManager $manager */ public function load(ObjectManager $manager) { if (!$manager instanceof DocumentManager) { $class = get_class($manager); throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '{$class}' given."); } // tweak homepage $page = $manager->find(null, '/cms/simple'); $page->setBody('Hello'); $page->setDefault('_template', 'AcmeDemoBundle::home.html.twig'); // add menu item for home $menuRoot = $manager->find(null, '/cms/simple'); $homeMenuNode = new MenuNode('home'); $homeMenuNode->setLabel('Home'); $homeMenuNode->setParentDocument($menuRoot); $homeMenuNode->setContent($page); $manager->persist($homeMenuNode); // load the pages Fixtures::load(array(__DIR__ . '/../../Resources/data/pages.yml'), $manager); // add menu item for login $loginMenuNode = new MenuNode('login'); $loginMenuNode->setLabel('Admin Login'); $loginMenuNode->setParentDocument($menuRoot); $loginMenuNode->setRoute('_demo_login'); $manager->persist($loginMenuNode); // load the blocks NodeHelper::createPath($manager->getPhpcrSession(), '/cms/content/blocks'); Fixtures::load(array(__DIR__ . '/../../Resources/data/blocks.yml'), $manager); // save the changes $manager->flush(); }
private function createBasePaths(SessionInterface $session, array $basePaths) { foreach ($basePaths as $path) { NodeHelper::createPath($session, $path); } $session->save(); }
public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/test/menus'); NodeHelper::createPath($manager->getPhpcrSession(), '/test/routes/contents'); $this->menuRoot = $manager->find(null, '/test/menus'); $this->routeRoot = $manager->find(null, '/test/routes'); $this->loadMenu($manager); $manager->flush(); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $session = $manager->getPhpcrSession(); $basePath = DIRECTORY_SEPARATOR . Website::WEBSITE_PREFIX; // Create the path in the repository NodeHelper::createPath($session, $basePath); $this->getFactory()->create(array('path' => $basePath . DIRECTORY_SEPARATOR . 'symfony-prestacms', 'name' => 'symfony-prestacms', 'available_locales' => array('fr', 'en'), 'default_locale' => 'en', 'theme' => 'creative')); $manager->flush(); }
public function load(ObjectManager $manager) { $session = $manager->getPhpcrSession(); $basepath = $this->container->getParameter('cmf_menu.persistence.phpcr.menu_basepath'); $content_path = $this->container->getParameter('cmf_content.persistence.phpcr.content_basepath'); NodeHelper::createPath($session, $basepath); $root = $manager->find(null, $basepath); $main = $this->createMenuNode($manager, $root, 'main', 'Home', $manager->find(null, "/cms/content/pages/home")); $this->createMenuNode($manager, $main, 'about', 'About', $manager->find(null, "/cms/content/pages/about")); $postsNode = $this->createMenuNode($manager, $main, 'posts', 'Liste des posts'); $posts = $manager->getRepository('AcmeBasicCmsBundle:Post')->findAll(); /** @var Post $post */ foreach ($posts as $post) { $this->createMenuNode($manager, $postsNode, $post->getSlug(), $post->getTitle(), $post); } // $menu = new Menu(); // $menu->setName('main-menu'); // $menu->setLabel('Main Menu'); // $menu->setParentDocument($menuParent); // $dm->persist($menu); // // $homeMenuNode = new MenuNode(); // $homePage = $dm->find('Acme\BasicCmsBundle\Document\Page', '/cms/content/pages/home'); // $homeMenuNode->setName($homePage->getSlug()); // $homeMenuNode->setLabel($homePage->getTitle()); // $homeMenuNode->setContent($homePage); // $homeMenuNode->setParentDocument($menu); // $dm->persist($homeMenuNode); // // $aboutMenuNode = new MenuNode(); // $aboutPage = $dm->find('Acme\BasicCmsBundle\Document\Page', '/cms/content/pages/about'); // $aboutMenuNode->setName($aboutPage->getSlug()); // $aboutMenuNode->setLabel($aboutPage->getTitle()); // $aboutMenuNode->setContent($aboutPage); // $aboutMenuNode->setParentDocument($homeMenuNode); // $dm->persist($aboutMenuNode); // // $postsMenuNode = new MenuNode(); // $postsMenuNode->setName('posts'); // $postsMenuNode->setLabel('Liste des posts'); // $postsMenuNode->setParentDocument($menu); // $dm->persist($postsMenuNode); // // $posts = $dm->getRepository('AcmeBasicCmsBundle:Post')->findAll(); // // /** @var Post $post */ // foreach ($posts as $post) { // $postMenuNode = new MenuNode(); // $postMenuNode->setName($post->getSlug()); // $postMenuNode->setLabel($post->getTitle()); // $postMenuNode->setContent($post); // $postMenuNode->setParentDocument($postsMenuNode); // $dm->persist($postMenuNode); // } $manager->flush(); }
/** * Load data fixtures with the passed EntityManager * * @param ObjectManager|DocumentManager $manager */ public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/cms/routes'); $routeBase = $manager->find(null, '/cms/routes'); $route = new Route(); $route->setPosition($routeBase, 'route_only'); $route->addDefaults(['_controller' => 'froscon_application.controller.default:routeOnlyAction']); $manager->persist($route); $manager->flush(); }
public function setUp() { $this->fetchDbParameters(); $this->connection = DriverManager::getConnection($this->params); $this->createEntityManager(); $this->createDocumentManager(); $this->resetFunctionalNode($this->dm); $this->createObjectAdapterManager(); NodeHelper::createPath($this->dm->getPhpcrSession(), '/functional'); $this->base = $this->dm->find(null, '/functional'); $this->createBaseTables(); }
public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/test'); $testDataDir = realpath(__DIR__ . '/../../app/Resources/data'); $root = $manager->find(null, '/test'); // media root $mediaRoot = new Generic(); $mediaRoot->setNodename('media'); $mediaRoot->setParent($root); $manager->persist($mediaRoot); // content root $contentRoot = new Generic(); $contentRoot->setNodename('content'); $contentRoot->setParent($root); $manager->persist($contentRoot); // File $file = new File(); $file->setParent($mediaRoot); $file->setName('file-1.txt'); $file->setContentFromString('Test file 1.'); $file->setContentType('text/plain'); $manager->persist($file); // Image $image = new Image(); $image->setParent($mediaRoot); $image->setName('cmf-logo.png'); $image->setFileContentFromFilesystem($testDataDir . '/cmf-logo.png'); $manager->persist($image); $image2 = new Image(); $image2->setParent($contentRoot); $image2->setName('cmf-logo-2.png'); $image2->setFileContentFromFilesystem($testDataDir . '/cmf-logo.png'); $manager->persist($image2); // Content with image $content = new Content(); $content->setParent($contentRoot); $content->setName('content-with-image'); $content->setTitle('Content document with image embedded'); $contentImage = new Image(); $contentImage->setFileContentFromFilesystem($testDataDir . '/cmf-logo.png'); $content->setFile($contentImage); $manager->persist($content); // Content with file $content2 = new Content(); $content2->setParent($contentRoot); $content2->setName('content-with-file'); $content2->setTitle('Content document with file attached'); $contentFile = new File(); $contentFile->setFileContentFromFilesystem($testDataDir . '/testfile.txt'); $content2->setFile($contentFile); $manager->persist($content2); $manager->flush(); }
/** * Load data from the old Camdram schema into the PHPCR * * Execute by calling php app/console doctrine:phpcr:fixtures:load */ public function load(ObjectManager $dm) { NodeHelper::createPath($dm->getPhpcrSession(), '/cms/pages'); $parent = $dm->find(null, '/cms/pages'); $em = $this->getContainer()->get('doctrine.orm.entity_manager'); $root_page = new CmsPage(); $root_page->setSlug('infobase'); $root_page->setTitle('infobase'); $root_page->setParent($parent); $dm->persist($root_page); // This magic number is based on inspection of the existing Camdram database. $this->add_child_nodes($dm, $em, 119, $root_page); $dm->flush(); }
/** * @param \Doctrine\ODM\PHPCR\DocumentManager $dm */ public function load(ObjectManager $dm) { $session = $dm->getPhpcrSession(); $basepath = $this->container->getParameter('cmf_menu.persistence.phpcr.menu_basepath'); $content_path = $this->container->getParameter('cmf_content.persistence.phpcr.content_basepath'); NodeHelper::createPath($session, $basepath); $root = $dm->find(null, $basepath); /** @var $MenuNode MenuNode */ $main = $this->createMenuNode($dm, $root, 'main', 'Home', $dm->find(null, "{$content_path}/home")); $main->setChildrenAttributes(array("class" => "menu_main")); $about_us = $this->createMenuNode($dm, $main, 'about-us', 'About Us', $dm->find(null, "{$content_path}/about-us")); $news = $this->createMenuNode($dm, $main, 'news', 'News', $dm->find(null, "{$content_path}/news")); $dm->flush(); }
public function load(ObjectManager $manager) { $session = $manager->getPhpcrSession(); $basePath = $this->container->getParameter('cmf_simple_cms.persistence.phpcr.basepath'); NodeHelper::createPath($session, preg_replace('#/[^/]*$#', '', $basePath)); $root = $manager->find(null, $basePath); if (!$root) { $root = new Page(); $root->setId($basePath); $root->setTitle('Home Page'); } $manager->persist($root); $manager->flush(); }
public function load(ObjectManager $manager) { $session = $manager->getPhpcrSession(); $basepath = $this->container->getParameter('symfony_cmf_simple_cms.basepath'); if ($session->nodeExists($basepath)) { $session->removeItem($basepath); } NodeHelper::createPath($session, $basepath); $base = $manager->find(null, $basepath); $root = $this->createPage($manager, $base, 'service', 'root', 'root page of service menu, never used', ''); $this->createPage($manager, $root, 'about', 'About us', 'Some information about us', 'The about us page with some content'); $this->createPage($manager, $root, 'contact', 'Contact', 'A contact page', 'Please send an email to symfony-cmf-devs@groups.google.com'); $manager->flush(); }
/** * @param ManagerRegistry $registry */ public function init(ManagerRegistry $registry) { $documentManager = $registry->getManager(); if ($documentManager->find(null, $this->basePath)) { return; } $homepage = new Homepage(); $homepage->setName($this->basePath); $documentManager->persist($homepage); $documentManager->flush(); $session = $registry->getConnection(); // Create Fixtures NodeHelper::createPath($session, $this->basePath . '/fixtures/routes'); $session->save(); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $this->manager = $manager; $session = $manager->getPhpcrSession(); $website = $manager->find(null, '/website/symfony-prestacms'); NodeHelper::createPath($session, '/website/symfony-prestacms/page'); $root = $manager->find(null, '/website/symfony-prestacms/page'); $yaml = new Parser(); $datas = $yaml->parse(file_get_contents(__DIR__ . '/../data/page.yml')); foreach ($datas['pages'] as $pageConfiguration) { $pageConfiguration['website'] = $website; $pageConfiguration['parent'] = $root; $this->getFactory()->create($pageConfiguration); } $this->manager->flush(); }
/** * Load data fixtures with the passed DocumentManager * * @param DocumentManager $manager */ public function load(ObjectManager $manager) { $this->setupTranslator(); // load the blocks foreach ($this->domains as $domain => $sections) { $parent = $manager->find(null, '/cms/content/blocks/' . $domain); if (null == $parent) { NodeHelper::createPath($manager->getPhpcrSession(), '/cms/content/blocks/' . $domain); $parent = $manager->find(null, '/cms/content/blocks/' . $domain); } foreach ($sections as $section => $messages) { $this->blockCreator($parent, $section, $domain, $manager); } } // save the changes $manager->flush(); }
public function init(ManagerRegistry $registry) { $dm = $registry->getManager(); if ($dm->find(null, $this->basePath)) { return; } $site = new Site(); $site->setId($this->basePath); $dm->persist($site); $dm->flush(); $session = $registry->getConnection(); // create the 'cms', 'pages', and 'posts' nodes NodeHelper::createPath($session, $this->basePath . '/pages'); NodeHelper::createPath($session, $this->basePath . '/posts'); NodeHelper::createPath($session, $this->basePath . '/routes'); $session->save(); }
/** * {@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(); }
public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/test'); $root = $manager->find(null, '/test'); $parent = new Generic(); $parent->setParent($root); $parent->setNodename('routing'); $manager->persist($parent); $route = new Route(); $route->setParentDocument($parent); $route->setName('route-1'); $manager->persist($route); $redirectRoute = new RedirectRoute(); $redirectRoute->setParentDocument($parent); $redirectRoute->setName('redirect-route-1'); $manager->persist($redirectRoute); $manager->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) { $documentManager = $registry->getManager(); if ($documentManager->find(null, $this->basePath)) { return; } $site = new Site(); $site->setId($this->basePath); $documentManager->persist($site); $documentManager->flush(); $session = $registry->getConnection(); NodeHelper::createPath($session, $this->basePath . '/articles'); NodeHelper::createPath($session, $this->basePath . '/events'); NodeHelper::createPath($session, $this->basePath . '/pages'); NodeHelper::createPath($session, $this->basePath . '/posts'); NodeHelper::createPath($session, $this->basePath . '/routes'); $session->save(); }
public function load(ObjectManager $manager) { $session = $manager->getPhpcrSession(); $basepath = '/cms/piccolo'; NodeHelper::createPath($session, $basepath); $yaml = new Parser(); $data = $yaml->parse(file_get_contents(__DIR__ . '/../../Resources/data/page.yml')); $parent = $manager->find(null, $basepath); foreach ($data['static'] as $overview) { $path = $basepath . '/' . $overview['name']; $page = $manager->find(null, $path); if (!$page) { $class = isset($overview['class']) ? $overview['class'] : 'ConnectHolland\\PiccoloContentBundle\\Document\\StandardPage'; $page = new $class(); $page->setName($overview['name']); $page->setParent($parent); // Routing $template = isset($overview['template']) ? $overview['template'] : 'ConnectHollandMainBundle:Page:Standard.html.twig'; $page->setTemplate($template); $manager->persist($page); } if (is_array($overview['title'])) { // Multilanguage foreach ($overview['title'] as $locale => $title) { $page->setTitle($title); $page->setBody($overview['body'][$locale]); $manager->bindTranslation($page, $locale); } } else { $page->setTitle($overview['title']); $page->setBody($overview['body']); if ($class == 'ConnectHolland\\PiccoloContentBundle\\Document\\NewsPage') { $page->setDate(new \DateTime($overview['date'])); } } if (isset($overview['blocks'])) { foreach ($overview['blocks'] as $name => $block) { $this->loadBlock($manager, $page, $name, $block); } } } $manager->flush(); //to get ref id populated }
public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/test'); NodeHelper::createPath($manager->getPhpcrSession(), '/test/content'); NodeHelper::createPath($manager->getPhpcrSession(), '/test/routes'); $contentRoot = $manager->find(null, '/test/content'); $routeRoot = $manager->find(null, '/test/routes'); $sitemapAwareContent = new SitemapAwareContent(); $sitemapAwareContent->setIsVisibleForSitemap(true)->setTitle('Sitemap Aware Content')->setName('sitemap-aware')->setParentDocument($contentRoot)->setBody('Content for that is sitemap aware'); $manager->persist($sitemapAwareContent); $manager->bindTranslation($sitemapAwareContent, 'en'); $sitemapAwareContent->setTitle('Content für die Sitemap')->setBody('Das sollte die Deutsche Version des Contents sein.'); $manager->bindTranslation($sitemapAwareContent, 'de'); $route = new Route(); $route->setPosition($routeRoot, 'sitemap-aware'); $route->setContent($sitemapAwareContent); $manager->persist($route); $nonPublishedContent = new SitemapAwareWithPublishWorkflowContent(); $nonPublishedContent->setIsVisibleForSitemap(true); $nonPublishedContent->setPublishable(false); $nonPublishedContent->setTitle('Sitemap Aware Content non publish')->setName('sitemap-aware-non-publish')->setParentDocument($contentRoot)->setBody('Content for that is sitemap aware, that is not publish'); $manager->persist($nonPublishedContent); $route = new Route(); $route->setPosition($routeRoot, 'sitemap-aware-non-publish'); $route->setContent($nonPublishedContent); $manager->persist($route); $publishedContent = new SitemapAwareWithPublishWorkflowContent(); $publishedContent->setIsVisibleForSitemap(true); $publishedContent->setPublishable(true); $publishedContent->setTitle('Sitemap Aware Content publish')->setName('sitemap-aware-publish')->setParentDocument($contentRoot)->setBody('Content for that is sitemap aware, that is publish'); $manager->persist($publishedContent); $route = new Route(); $route->setPosition($routeRoot, 'sitemap-aware-publish'); $route->setContent($publishedContent); $manager->persist($route); $lastModifiedContent = new SitemapAwareWithLastModifiedDateContent(); $lastModifiedContent->setIsVisibleForSitemap(true)->setLastModified(new \DateTime('2016-07-06', new \DateTimeZone('Europe/Berlin')))->setTitle('Sitemap Aware Content last mod date')->setName('sitemap-aware-last-mod-date')->setParentDocument($contentRoot)->setBody('Content for that is sitemap aware, that has last modified date.'); $manager->persist($lastModifiedContent); $route = new Route(); $route->setPosition($routeRoot, 'sitemap-aware-last-mod-date'); $route->setContent($lastModifiedContent); $manager->persist($route); $manager->flush(); }
/** * @param \Doctrine\ODM\PHPCR\DocumentManager $manager */ public function load(ObjectManager $manager) { if (!$manager instanceof DocumentManager) { $class = get_class($manager); throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '{$class}' given."); } $session = $manager->getPhpcrSession(); $basepath = $this->container->getParameter('cmf_menu.persistence.phpcr.menu_basepath'); $content_path = $this->container->getParameter('cmf_content.persistence.phpcr.content_basepath'); NodeHelper::createPath($session, $basepath); $root = $manager->find(null, $basepath); $labels = array('en' => 'Home', 'de' => 'Start', 'fr' => 'Accueil'); /** @var $main Menu */ $main = $this->createMenuNode($manager, $root, 'main', $labels, $manager->find(null, "{$content_path}/home")); $main->setChildrenAttributes(array("class" => "menu_main")); if ($session->getRepository()->getDescriptor(RepositoryInterface::QUERY_FULL_TEXT_SEARCH_SUPPORTED)) { $this->createMenuNode($manager, $main, 'search-item', 'Search', null, null, 'liip_search'); } $this->createMenuNode($manager, $main, 'admin-item', 'Admin', null, null, 'sonata_admin_dashboard'); $projects = $this->createMenuNode($manager, $main, 'projects-item', array('en' => 'Projects', 'de' => 'Projekte', 'fr' => 'Projets'), $manager->find(null, "{$content_path}/projects")); $this->createMenuNode($manager, $projects, 'cmf-item', 'Symfony CMF', $manager->find(null, "{$content_path}/cmf")); $company = $this->createMenuNode($manager, $main, 'company-item', array('en' => 'Company', 'de' => 'Firma', 'fr' => 'Entreprise'), $manager->find(null, "{$content_path}/company")); $this->createMenuNode($manager, $company, 'team-item', array('en' => 'Team', 'de' => 'Team', 'fr' => 'Equipe'), $manager->find(null, "{$content_path}/team")); $this->createMenuNode($manager, $company, 'more-item', array('en' => 'More', 'de' => 'Mehr', 'fr' => 'Plus'), $manager->find(null, "{$content_path}/more")); $demo = $this->createMenuNode($manager, $main, 'demo-item', 'Demo', $manager->find(null, "{$content_path}/demo")); //TODO: this should be possible without a content as the controller might not need a content. support directly having the route document as "content" in the menu document? $this->createMenuNode($manager, $demo, 'controller-item', 'Explicit controller', $manager->find(null, "{$content_path}/demo_controller")); $this->createMenuNode($manager, $demo, 'template-item', 'Explicit template', $manager->find(null, "{$content_path}/demo_template")); $this->createMenuNode($manager, $demo, 'type-item', 'Route type to controller', $manager->find(null, "{$content_path}/demo_type")); $this->createMenuNode($manager, $demo, 'class-item', 'Class to controller', $manager->find(null, "{$content_path}/demo_class")); $this->createMenuNode($manager, $demo, 'test-item', 'Normal Symfony Route', null, null, 'symfony_route'); $this->createMenuNode($manager, $demo, 'external-item', 'External Link', null, 'http://cmf.symfony.com/'); $publicationDemo = $this->createMenuNode($manager, $main, 'publication-demo-item', 'Publication Demo', $manager->find(null, "{$content_path}/publication_demo")); $this->createMenuNode($manager, $publicationDemo, 'not-published', 'Not published', $manager->find(null, "{$content_path}/not_published")); $this->createMenuNode($manager, $publicationDemo, 'published-tomorrow', 'Published tomorrow', $manager->find(null, "{$content_path}/published_tomorrow")); $singlelocale = $this->createMenuNode($manager, $main, 'singlelocale-item', array('en' => 'singlelocale'), $manager->find(null, "{$content_path}/singlelocale")); $this->createMenuNode($manager, $singlelocale, 'singlelocale-sub-item', array('en' => 'singlelocale child'), $manager->find(null, "{$content_path}/singlelocale")); $seo = $this->createMenuNode($manager, $main, 'seo', 'SEO', $manager->find(null, "{$content_path}/simple-seo-example")); $this->createMenuNode($manager, $seo, 'simple-seo-example', array('en' => 'Seo-Simple-Content'), $manager->find(null, "{$content_path}/simple-seo-example")); $this->createMenuNode($manager, $seo, 'demo-seo-extractor', array('en' => 'Seo-Extractor'), $manager->find(null, "{$content_path}/demo-seo-extractor")); $this->createMenuNode($manager, $seo, 'simple-seo-property', array('en' => 'Seo-Extra-Properties'), $manager->find(null, "{$content_path}/simple-seo-property")); $this->createMenuNode($manager, $main, 'routing-auto-item', array('en' => 'Auto routing example', 'de' => 'Auto routing beispiel', 'fr' => 'Auto routing exemple'), $manager->find(null, "{$content_path}/news/RoutingAutoBundle generates routes!")); $manager->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(); }
public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/test'); $root = $manager->find(null, '/test'); $parent = new Generic(); $parent->setParentDocument($root); $parent->setNodename('routing'); $manager->persist($parent); $routeCollection = new Route(); $routeCollection->setParentDocument($parent); $routeCollection->setMethods(array('POST', 'GET', 'PUT')); # Todo check if we can add a type and set defaults prePersist? $routeCollection->setName('collection'); $manager->persist($routeCollection); $route = new Route(); $route->setParentDocument($routeCollection); $route->setName('get-1'); $route->setMethods(array(Request::METHOD_GET)); $manager->persist($route); $route = new Route(); $route->setParentDocument($routeCollection); $route->setName('post-1'); $route->setMethods(array(Request::METHOD_POST)); $manager->persist($route); $route = new Route(); $route->setParentDocument($routeCollection); $route->setName('put-1'); $route->setMethods(array(Request::METHOD_PUT)); $manager->persist($route); $route = new Route(); $route->setParentDocument($routeCollection); $route->setName('delete-1'); $route->setMethods(array(Request::METHOD_DELETE)); $manager->persist($route); $route = new Route(); $route->setParentDocument($routeCollection); $route->setName('patch-1'); $route->setMethods(array(Request::METHOD_PATCH)); $manager->persist($route); $manager->flush(); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $this->manager = $manager; $session = $manager->getPhpcrSession(); NodeHelper::createPath($session, '/website/symfony-prestacms/menu'); $root = $manager->find(null, '/website/symfony-prestacms/menu'); $configuration = array('parent' => $root, 'name' => 'main', 'title' => array('en' => 'Main navigation', 'fr' => 'Menu principal'), 'children_content_path' => '/website/symfony-prestacms/page', 'children' => array()); $yaml = new Parser(); $datas = $yaml->parse(file_get_contents(__DIR__ . '/../data/page.yml')); foreach ($datas['pages'] as $key => $pageConfiguration) { if (isset($pageConfiguration['in_navigation']) && $pageConfiguration['in_navigation'] === true) { if (isset($pageConfiguration['meta']['title'])) { $pageConfiguration['title'] = $pageConfiguration['meta']['title']; } $configuration['children'][] = $pageConfiguration; } } $main = $this->getFactory()->create($configuration); $main->setChildrenAttributes(array("class" => "nav")); $manager->flush(); }