示例#1
0
 public function testGetUniquePath()
 {
     // machines & machines-1 exists
     $result = $this->rlpMapper->getUniquePath('/products/machines', 'sulu_io', 'de');
     $this->assertEquals('/products/machines-2', $result);
     $this->assertTrue($this->rlpMapper->unique($result, 'sulu_io', 'de'));
     // drill & drill-1 exists
     $result = $this->rlpMapper->getUniquePath('/products/machines/drill', 'sulu_io', 'de');
     $this->assertEquals('/products/machines/drill-2', $result);
     $this->assertTrue($this->rlpMapper->unique($result, 'sulu_io', 'de'));
     // products exists
     $result = $this->rlpMapper->getUniquePath('/products', 'sulu_io', 'de');
     $this->assertEquals('/products-1', $result);
     $this->assertTrue($this->rlpMapper->unique($result, 'sulu_io', 'de'));
     // news not exists
     $result = $this->rlpMapper->getUniquePath('/news', 'sulu_io', 'de');
     $this->assertEquals('/news', $result);
     $this->assertTrue($this->rlpMapper->unique($result, 'sulu_io', 'de'));
 }
示例#2
0
 /**
  * returns whole path for given ContentNode.
  *
  * @param string $title        title of new node
  * @param string $parentPath   parent path of new contentNode
  * @param string $webspaceKey  key of portal
  * @param string $languageCode
  * @param string $segmentKey
  *
  * @return string whole path
  */
 public function generate($title, $parentPath, $webspaceKey, $languageCode, $segmentKey = null)
 {
     // title should not have a slash
     $title = str_replace('/', '-', $title);
     // get generated path from childClass
     $path = $this->generatePath($title, $parentPath);
     // cleanup path
     $path = $this->cleaner->cleanup($path, $languageCode);
     // get unique path
     $path = $this->mapper->getUniquePath($path, $webspaceKey, $languageCode, $segmentKey);
     return $path;
 }