Пример #1
0
 public function load(ObjectManager $manager)
 {
     $base = $manager->find(null, '/test/page');
     $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();
 }
Пример #2
0
 public function testPage()
 {
     $page = new Page(array('add_locale_pattern' => true));
     $page->setParentDocument($this->baseDocument);
     $page->setName('page-name');
     $page->setTitle('Page Title');
     $page->setLabel('Page Label');
     $page->setBody('This is body');
     $page->setPublishable(false);
     $page->setPublishStartDate(new \DateTime('2013-06-18'));
     $page->setPublishEndDate(new \DateTime('2013-06-18'));
     $page->setExtras(array('extra_1' => 'foobar', 'extra_2' => 'barfoo'));
     $this->dm->persist($page);
     $this->dm->flush();
     $this->dm->clear();
     $page = $this->dm->find(null, '/test/page-name');
     $this->assertNotNull($page);
     $this->assertTrue($page->getOption('add_locale_pattern'));
     $this->assertEquals('Page Title', $page->getTitle());
     $this->assertEquals('Page Label', $page->getLabel());
     $this->assertEquals('This is body', $page->getBody());
     $this->assertEquals(array('extra_1' => 'foobar', 'extra_2' => 'barfoo'), $page->getExtras());
     // test publish start and end
     $publishStartDate = $page->getPublishStartDate();
     $publishEndDate = $page->getPublishEndDate();
     $this->assertInstanceOf('\\DateTime', $publishStartDate);
     $this->assertInstanceOf('\\DateTime', $publishEndDate);
     $this->assertEquals('2013-06-18', $publishStartDate->format('Y-m-d'));
     $this->assertEquals('2013-06-18', $publishEndDate->format('Y-m-d'));
     // test multi-lang
     $page->setLocale('fr');
     $page->setTitle('french');
     $this->dm->persist($page);
     $this->dm->flush();
     $this->dm->clear();
     $page = $this->dm->findTranslation(null, '/test/page-name', 'fr');
     $this->assertEquals('fr', $page->getLocale());
     $this->assertEquals('french', $page->getTitle());
     // test node
     $node = $page->getNode();
     $this->assertInstanceOf('PHPCR\\NodeInterface', $node);
 }
Пример #3
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();
 }