示例#1
0
 public function getNodePath($workspace, $path, $withFilename = true)
 {
     $path = PathHelper::normalizePath($path);
     if (substr($path, 0, 1) == '/') {
         $path = substr($path, 1);
     }
     if ($path) {
         $path .= '/';
     }
     $nodeRecordPath = Storage::WORKSPACE_PATH . '/' . $workspace . '/' . $path . 'node.yml';
     if ($withFilename === false) {
         $nodeRecordPath = dirname($nodeRecordPath);
     }
     return $nodeRecordPath;
 }
示例#2
0
 /**
  * changes path node to history node.
  *
  * @param NodeInterface    $node
  * @param SessionInterface $session
  * @param string           $absSrcPath
  * @param string           $absDestPath
  */
 private function changePathToHistory(NodeInterface $node, SessionInterface $session, $absSrcPath, $absDestPath)
 {
     // get new path node
     $relPath = str_replace($absSrcPath, '', $node->getPath());
     $newPath = PathHelper::normalizePath($absDestPath . $relPath);
     $newPathNode = $session->getNode($newPath);
     // set history to true and set content to new path
     $node->setProperty('sulu:content', $newPathNode);
     $node->setProperty('sulu:history', true);
     // get referenced history
     /** @var PropertyInterface $property */
     foreach ($node->getReferences('sulu:content') as $property) {
         $property->getParent()->setProperty('sulu:content', $newPathNode);
     }
 }
示例#3
0
 /**
  * Implement the workspace clone method. It is dispatched immediately.
  *      http://www.day.com/specs/jcr/2.0/3_Repository_Model.html#3.10%20Corresponding%20Nodes
  *      http://www.day.com/specs/jcr/2.0/10_Writing.html#10.8%20Cloning%20and%20Updating%20Nodes
  *
  * @param string  $srcWorkspace   the name of the workspace from which the copy is to be made.
  * @param string  $srcAbsPath     the path of the node to be cloned.
  * @param string  $destAbsPath    the location to which the node at srcAbsPath is to be cloned in this workspace.
  * @param boolean $removeExisting
  *
  * @throws \PHPCR\UnsupportedRepositoryOperationException
  * @throws \PHPCR\ItemExistsException
  *
  * @see Workspace::cloneFrom()
  */
 public function cloneFromImmediately($srcWorkspace, $srcAbsPath, $destAbsPath, $removeExisting)
 {
     if (!$this->transport instanceof WritingInterface) {
         throw new UnsupportedRepositoryOperationException('Transport does not support writing');
     }
     $srcAbsPath = PathHelper::normalizePath($srcAbsPath);
     $destAbsPath = PathHelper::normalizePath($destAbsPath, true);
     if (!$removeExisting && $this->session->nodeExists($destAbsPath)) {
         throw new ItemExistsException('Node already exists at destination and removeExisting is false');
     }
     $this->transport->cloneFrom($srcWorkspace, $srcAbsPath, $destAbsPath, $removeExisting);
 }
示例#4
0
 /**
  * @dataProvider dataproviderNormalizePathInvalid
  */
 public function testNormalizePathInvalidNoThrow($input)
 {
     $this->assertFalse(PathHelper::normalizePath($input, true, false));
 }