Esempio n. 1
0
 /**
  * @param DocumentManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $this->root = $manager->find(null, '/test');
     $doc = new TestDocument();
     $doc->id = '/test/doc';
     $doc->bool = true;
     $doc->date = new \DateTime('2014-01-14');
     $doc->integer = 42;
     $doc->long = 24;
     $doc->number = 3.14;
     $doc->text = 'text content';
     $manager->persist($doc);
     $doc = new TestDocument();
     $doc->id = '/test/doc2';
     $doc->bool = true;
     $doc->date = new \DateTime('2014-01-14');
     $doc->integer = 42;
     $doc->long = 24;
     $doc->number = 3.14;
     $doc->text = 'text content';
     $manager->persist($doc);
     $ref = new ReferrerDocument();
     $ref->id = '/test/ref';
     $ref->addDocument($doc);
     $manager->persist($ref);
     $manager->flush();
     $node = $manager->getPhpcrSession()->getNode('/test/doc');
     $node->addNode('child');
     $node->addNode('second');
     $manager->getPhpcrSession()->save();
     $manager->clear();
 }
 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();
 }
Esempio n. 3
0
 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();
 }
Esempio n. 4
0
    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();
    }
Esempio n. 5
0
 /**
  * {@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();
 }
Esempio n. 6
0
 /**
  * {@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();
 }
Esempio n. 7
0
 /**
  * {@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();
 }
 public function load(ObjectManager $manager)
 {
     $session = $manager->getPhpcrSession();
     $root = $session->getRootNode();
     /*
      * /a
      * /a/b
      * /a/b/c
      * /a/b/d
      * /a/b/e
      * /a/f
      * /a/f/g
      * /a/f/g/h
      * /a/i
      */
     $a = $root->addNode('a');
     $b = $a->addNode('b');
     $c = $b->addNode('c');
     $c->addMixin('phpcr:managed');
     $c->setProperty('phpcr:class', 'Symfony\\Cmf\\Bundle\\CoreBundle\\Tests\\Resources\\Document\\RouteAware');
     $b->addNode('d');
     $e = $b->addNode('e');
     $e->addMixin('phpcr:managed');
     $e->setProperty('phpcr:class', 'Symfony\\Cmf\\Bundle\\CoreBundle\\Tests\\Resources\\Document\\RouteAware');
     $f = $a->addNode('f');
     $g = $f->addNode('g');
     $g->addNode('h');
     $a->addNode('i');
     $session->save();
 }
Esempio n. 9
0
 /**
  * {@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();
 }
Esempio n. 10
0
 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();
 }
Esempio n. 11
0
 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();
 }
Esempio n. 13
0
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var $session \PHPCR\SessionInterface */
     $session = $manager->getPhpcrSession();
     $root = $session->getNode('/');
     $root->addNode('users');
     $this->createUser('User Foo', 'user', 'abc123', '*****@*****.**', array('ROLE_USER'), $manager);
     $this->createUser('John Editor', 'editor', 'abc123', '*****@*****.**', array('ROLE_EDITOR'), $manager);
     $this->createUser('Administrator', 'admin', 'abc123', '*****@*****.**', array('ROLE_ADMIN'), $manager);
     $manager->flush();
 }
Esempio n. 14
0
 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();
 }
Esempio n. 15
0
 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();
 }
Esempio n. 16
0
 /**
  * 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();
 }
Esempio n. 18
0
 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();
 }
Esempio n. 19
0
 /**
  * {@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();
 }
Esempio n. 20
0
 /**
  * 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();
 }
Esempio n. 21
0
 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();
 }
 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
 }
Esempio n. 23
0
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $session = $manager->getPhpcrSession();
     $session->getRootNode()->addNode('categories');
     /** @var $parent \Doctrine\ODM\PHPCR\Document\Generic */
     $parent = $manager->find(null, '/categories');
     $this->addCategory($manager, 'Homepage', 'Category for homepage articles', $parent, true);
     $this->addCategory($manager, 'Category A', 'Description', $parent);
     $this->addCategory($manager, 'Category B', 'Description', $parent);
     $this->addCategory($manager, 'Category C', 'Description', $parent);
     $category = $this->addCategory($manager, 'Test', 'This is the description of the test category', $parent);
     $this->addCategory($manager, 'Child', 'Description of child category', $category);
     /*
           $category = $this->addCategory($manager, 'CategoryD', 'This is the description of the test category', $parent);
           $this->addCategory($manager, 'Child', 'Description of child category', $category);
     */
     $manager->flush();
     $this->addTranslation($manager, $category, 'es', 'Prueba', 'Esta es la descripción de la categoría de prueba');
 }
Esempio n. 24
0
 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();
 }
Esempio n. 25
0
 /**
  * {@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();
 }
 public function load(ObjectManager $dm)
 {
     $session = $dm->getPhpcrSession();
     $basepath = explode('/', $this->container->getParameter('symfony_cmf_simple_cms.basepath'));
     $rootname = array_pop($basepath);
     $basepath = implode('/', $basepath);
     if ($session->nodeExists($basepath)) {
         $session->removeItem($basepath);
     }
     NodeHelper::createPath($session, $basepath);
     $base = $dm->find(null, $basepath);
     $root = $this->createPage($dm, $base, $rootname, 'Welcome', array('' => array('Welcome to the CMF Standard Edition', 'This is should get you started with the Symfony CMF.')));
     $this->createPage($dm, $root, 'about', 'About us', array('' => array('Some information about us', 'The about us page with some content')));
     $this->createPage($dm, $root, 'privacy', 'Privacy Policy', array('' => array('Some information privacy', 'The privacy content')));
     $this->createPage($dm, $root, 'cookies', 'Cookies', array('' => array('Some information privacy', 'The privacy content')));
     $this->createPage($dm, $root, 'faqs', 'FAQ\'s', array('' => array('Some information privacy', 'The privacy content')));
     $this->createPage($dm, $root, 'testimonials', 'Testimonials', array('' => array('Some information privacy', 'The privacy content')));
     $this->createPage($dm, $root, 'report', 'Report an issue', array('' => array('A map of a location in the US', 'Have a look at the map to find us.')));
     $this->createPage($dm, $root, 'contact', 'Contact', array('' => array('A contact page', 'Please send an email to symfony-cmf-devs@groups.google.com')));
     $dm->flush();
 }
Esempio n. 27
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $root = $manager->find(null, '/test');
     $base = new Page();
     $base->setName('page');
     $base->setTitle('Simple Cms');
     $base->setLabel('Simple Cms');
     $base->setParent($root);
     $manager->persist($base);
     $page = new Page();
     $page->setName('homepage');
     $page->setTitle('Homepage');
     $page->setLabel('Homepage');
     $page->setPublishable(true);
     $page->setAddLocalePattern(true);
     $page->setParent($base);
     $page->setBody($this->getContent('homepage.html'));
     $manager->persist($page);
     $page = new Page();
     $page->setName('french-page');
     $page->setTitle('French Page');
     $page->setLabel('French Page');
     $page->setPublishable(true);
     $page->setAddLocalePattern(true);
     $page->setLocale('fr');
     $page->setBody($this->getContent('french-page.html'));
     $page->setParent($base);
     $manager->persist($page);
     $page = new Page();
     $page->setName('no-locale-prefix');
     $page->setTitle('No Locale Prefix');
     $page->setLabel('No Locale Prefix');
     $page->setPublishable(true);
     $page->setParent($base);
     $page->setBody($this->getContent('no-locale-prefix.html'));
     $page->setParent($base);
     $manager->persist($page);
     $manager->flush();
 }
 public function load(ObjectManager $manager)
 {
     $dataDir = __DIR__ . '/../../Resources/data';
     $session = $manager->getPhpcrSession();
     $yaml = new Parser();
     $basepath = $this->container->getParameter('cmf_simple_cms.persistence.phpcr.basepath');
     NodeHelper::createPath($session, preg_replace('#/[^/]*$#', '', $basepath));
     $data = $yaml->parse(file_get_contents($dataDir . '/page.yml'));
     foreach ($data['static'] as $overview) {
         $this->loadPage($manager, $basepath, $overview);
     }
     // load single pages
     $finder = new Finder();
     $finder->files()->name('*.yml')->in($dataDir . '/posts')->sortByName();
     foreach ($finder as $pageFile) {
         $post = array_merge(array('parent' => '/news', 'label' => false, 'format' => 'markdown', 'template' => 'cms/news_detail.html.twig'), $yaml->parse(file_get_contents($pageFile)));
         $this->loadPage($manager, $basepath, $post);
     }
     $data = $yaml->parse(file_get_contents(__DIR__ . '/../../Resources/data/external.yml'));
     $basepath = $this->container->getParameter('cmf_core.persistence.phpcr.basepath');
     $home = $manager->find(null, $basepath);
     foreach ($data['static'] as $name => $overview) {
         $item = new MenuNode();
         $item->setName($name);
         $item->setLabel($overview['label']);
         $item->setUri($overview['uri']);
         $item->setParentDocument($home);
         $manager->persist($item);
     }
     $blocks = $yaml->parse(file_get_contents(__DIR__ . '/../../Resources/data/block.yml'));
     $blockBasepath = $this->container->getParameter('cmf_block.persistence.phpcr.block_basepath');
     NodeHelper::createPath($session, $blockBasepath);
     $blocksHome = $manager->find(null, $blockBasepath);
     foreach ($blocks['static'] as $name => $block) {
         $this->loadBlock($manager, $blocksHome, $name, $block);
     }
     $manager->flush();
 }
Esempio n. 29
0
 public function load(ObjectManager $manager)
 {
     $session = $manager->getPhpcrSession();
     $basepath = $this->container->getParameter('symfony_cmf_content.static_basepath');
     NodeHelper::createPath($session, $basepath);
     $yaml = new Parser();
     $data = $yaml->parse(file_get_contents(__DIR__ . '/../static/page.yml'));
     foreach ($data['static'] as $overview) {
         $path = $basepath . '/' . $overview['name'];
         $page = $manager->find(null, $path);
         if (!$page) {
             $class = isset($overview['class']) ? $overview['class'] : 'Sandbox\\MainBundle\\Document\\EditableStaticContent';
             $page = new $class();
             $page->setPath($path);
             $manager->persist($page);
         }
         $page->name = $overview['name'];
         if (is_array($overview['title'])) {
             foreach ($overview['title'] as $locale => $title) {
                 $page->title = $title;
                 $page->body = $overview['content'][$locale];
                 $manager->bindTranslation($page, $locale);
             }
         } else {
             $page->title = $overview['title'];
             $page->body = $overview['content'];
         }
         if (isset($overview['blocks'])) {
             foreach ($overview['blocks'] as $name => $block) {
                 $this->loadBlock($manager, $page, $name, $block);
             }
         }
     }
     $manager->flush();
     //to get ref id populated
 }
Esempio n. 30
0
 public function load(ObjectManager $dm)
 {
     $session = $dm->getPhpcrSession();
     $basepath = $this->container->getParameter('symfony_cmf_menu.menu_basepath');
     $content_path = $this->container->getParameter('symfony_cmf_content.static_basepath');
     NodeHelper::createPath($session, $basepath);
     $root = $dm->find(null, $basepath);
     /** @var $menuitem MenuItem */
     $main = $this->createMenuItem($dm, $root, 'main', array('en' => 'Home', 'de' => 'Start', 'fr' => 'Accueil'), $dm->find(null, "{$content_path}/home"));
     $main->setChildrenAttributes(array("class" => "menu_main"));
     try {
         // run a dummy query to check if full text search is supported
         // TODO: is this covered by the capabilities API?
         $qb = $dm->createQueryBuilder();
         $factory = $qb->getQOMFactory();
         $qb->from($factory->selector('nt:unstructured'))->where($factory->fullTextSearch('foo', 'bar'))->execute();
         $this->createMenuItem($dm, $main, 'search-item', 'Search', null, null, 'search');
     } catch (\Exception $e) {
         // search not supported
     }
     $this->createMenuItem($dm, $main, 'admin-item', 'Admin', null, null, 'sonata_admin_dashboard');
     $projects = $this->createMenuItem($dm, $main, 'projects-item', array('en' => 'Projects', 'de' => 'Projekte', 'fr' => 'Projets'), $dm->find(null, "{$content_path}/projects"));
     $this->createMenuItem($dm, $projects, 'cmf-item', 'Symfony CMF', $dm->find(null, "{$content_path}/cmf"));
     $company = $this->createMenuItem($dm, $main, 'company-item', array('en' => 'Company', 'de' => 'Firma', 'fr' => 'Entreprise'), $dm->find(null, "{$content_path}/company"));
     $this->createMenuItem($dm, $company, 'team-item', array('en' => 'Team', 'de' => 'Team', 'fr' => 'Equipe'), $dm->find(null, "{$content_path}/team"));
     $this->createMenuItem($dm, $company, 'more-item', array('en' => 'More', 'de' => 'Mehr', 'fr' => 'Plus'), $dm->find(null, "{$content_path}/more"));
     $demo = $this->createMenuItem($dm, $main, 'demo-item', 'Demo', $dm->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->createMenuItem($dm, $demo, 'controller-item', 'Explicit controller', $dm->find(null, "{$content_path}/demo_controller"));
     $this->createMenuItem($dm, $demo, 'template-item', 'Explicit template', $dm->find(null, "{$content_path}/demo_template"));
     $this->createMenuItem($dm, $demo, 'alias-item', 'Route alias to controller', $dm->find(null, "{$content_path}/demo_alias"));
     $this->createMenuItem($dm, $demo, 'class-item', 'Class to controller', $dm->find(null, "{$content_path}/demo_class"));
     $this->createMenuItem($dm, $demo, 'test-item', 'Normal Symfony Route', null, null, 'test');
     $this->createMenuItem($dm, $demo, 'external-item', 'External Link', null, 'http://cmf.symfony.com/');
     $dm->flush();
 }