Exemple #1
0
 public function testCustomCanonicalURLs()
 {
     $cache = Core::make('cache/request');
     $cache->disable();
     $about = self::createPage('About');
     $contact = self::createPage('Contact Us', $about);
     $c = Page::getByID(3);
     $this->assertEquals('Contact Us', $c->getCollectionName());
     $this->assertEquals('/about/contact-us', $c->getCollectionPath());
     $p = new \Concrete\Core\Page\PagePath();
     $p->setPagePath('/contact');
     $p->setPageObject($contact);
     $p->setPagePathIsCanonical(true);
     $c->clearPagePaths();
     $db = Loader::db();
     $db->getEntityManager()->persist($p);
     $db->getEntityManager()->flush();
     $c = Page::getByID(3);
     $this->assertEquals('/contact', $c->getCollectionPath());
     $c->rescanCollectionPath();
     $c = Page::getByID(3);
     $this->assertEquals('/contact', $c->getCollectionPath());
 }
Exemple #2
0
 /**
  * Sets the canonical page path for a page.
  */
 public function setCanonicalPagePath($cPath, $isAutoGenerated = false)
 {
     $em = Database::get()->getEntityManager();
     $path = $this->getCollectionPathObject();
     if (is_object($path)) {
         $path->setPagePath($cPath);
     } else {
         $path = new \Concrete\Core\Page\PagePath();
         $path->setPagePath($cPath);
         $path->setPageObject($this);
     }
     $path->setPagePathIsAutoGenerated($isAutoGenerated);
     $path->setPagePathIsCanonical(true);
     $em->persist($path);
     $em->flush();
 }
 /**
  * Sets the canonical page path for a page.
  * @return void
  */
 public function setCanonicalPagePath($cPath)
 {
     $em = Loader::db()->getEntityManager();
     $path = $this->getCollectionPathObject();
     if (is_object($path)) {
         $path->setPagePath($cPath);
     } else {
         $path = new \Concrete\Core\Page\PagePath();
         $path->setPagePath($cPath);
         $path->setPageObject($this);
     }
     $path->setPagePathIsCanonical(true);
     $em->persist($path);
     $em->flush();
 }