當前位置: 首頁>>代碼示例>>PHP>>正文


PHP NodeInterface::getPath方法代碼示例

本文整理匯總了PHP中PHPCR\NodeInterface::getPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP NodeInterface::getPath方法的具體用法?PHP NodeInterface::getPath怎麽用?PHP NodeInterface::getPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PHPCR\NodeInterface的用法示例。


在下文中一共展示了NodeInterface::getPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 public function setUp()
 {
     $this->dm = $this->createDocumentManager(array(__DIR__));
     $repository = $this->dm->getPhpcrSession()->getRepository();
     if (!$repository->getDescriptor('node.type.management.orderable.child.nodes.supported')) {
         $this->markTestSkipped('PHPCR repository doesn\'t support orderable child nodes');
     }
     $this->node = $this->resetFunctionalNode($this->dm);
     $parent = $this->dm->find(null, $this->node->getPath());
     $node1 = new Generic();
     $node1->setParentDocument($parent);
     $node1->setNodename('source');
     $this->dm->persist($node1);
     $this->childrenNames = array('first', 'second', 'third', 'fourth');
     foreach ($this->childrenNames as $childName) {
         $child = new Generic();
         $child->setNodename($childName);
         $child->setParentDocument($node1);
         $this->dm->persist($child);
     }
     $node2 = new Generic();
     $node2->setNodename('target');
     $node2->setParentDocument($parent);
     $this->dm->persist($node2);
     $this->dm->flush();
     $this->dm->clear();
 }
開發者ID:steffenbrem,項目名稱:phpcr-odm,代碼行數:27,代碼來源:ReorderTest.php

示例2: loadFixtures

 public function loadFixtures()
 {
     $contentMapperRequest = ContentMapperRequest::create()->setType(Structure::TYPE_SNIPPET)->setTemplateKey('animal')->setLocale('en')->setUserId(1)->setData(['title' => 'ElePHPant'])->setState(StructureInterface::STATE_PUBLISHED);
     $this->snippet1 = $this->contentMapper->saveRequest($contentMapperRequest);
     $contentMapperRequest = ContentMapperRequest::create()->setType(Structure::TYPE_SNIPPET)->setTemplateKey('animal')->setLocale('de')->setUserId(1)->setData(['title' => 'Penguin'])->setState(StructureInterface::STATE_PUBLISHED);
     $this->snippet2 = $this->contentMapper->saveRequest($contentMapperRequest);
     $this->snippet1Node = $this->session->getNodeByIdentifier($this->snippet1->getUuid());
     $this->snippet1OriginalPath = $this->snippet1Node->getPath();
     $contentMapperRequest = ContentMapperRequest::create()->setUuid($this->snippet1->getUuid())->setType(Structure::TYPE_SNIPPET)->setTemplateKey('animal')->setLocale('de')->setUserId(1)->setData(['title' => 'English ElePHPant'])->setState(StructureInterface::STATE_PUBLISHED);
     $this->contentMapper->saveRequest($contentMapperRequest);
     $contentMapperRequest = ContentMapperRequest::create()->setType(Structure::TYPE_SNIPPET)->setTemplateKey('animal')->setLocale('en')->setUserId(1)->setData(['title' => 'Some other animal'])->setState(StructureInterface::STATE_PUBLISHED);
     $this->contentMapper->saveRequest($contentMapperRequest);
 }
開發者ID:Silwereth,項目名稱:sulu,代碼行數:13,代碼來源:ContentMapperSnippetTest.php

示例3: toJsonLD

 protected function toJsonLD(NodeInterface $node)
 {
     $data = $node->getPropertiesValues(null, false);
     $data['@'] = $node->getPath();
     $data['a'] = $node->getPrimaryNodeType();
     return $data;
 }
開發者ID:richardmiller,項目名稱:LiipVieBundle,代碼行數:7,代碼來源:PhpcrController.php

示例4: traverse

 /**
  * Traverse the node
  *
  * @param NodeInterface|null $node  The node to traverse, if it exists yet
  * @param array $segments  The element => token stack
  * @param array $result  The result
  *
  * @return null
  */
 private function traverse(array $segments, &$result = array(), $node = null)
 {
     $path = array();
     if (null !== $node) {
         $path = explode('/', substr($node->getPath(), 1));
     }
     do {
         list($element, $bitmask) = array_shift($segments);
         if ($bitmask & SelectorParser::T_STATIC) {
             $path[] = $element;
             if ($bitmask & SelectorParser::T_LAST) {
                 if ($node = $this->getNode($path)) {
                     $result[] = $node;
                     break;
                 }
             }
         }
         if ($bitmask & SelectorParser::T_PATTERN) {
             if (null === ($parentNode = $this->getNode($path))) {
                 return;
             }
             $children = $this->getChildren($parentNode, $element);
             foreach ($children as $child) {
                 if ($bitmask & SelectorParser::T_LAST) {
                     $result[] = $child;
                 } else {
                     $this->traverse($segments, $result, $child);
                 }
             }
             return;
         }
     } while ($segments);
 }
開發者ID:frogriotcom,項目名稱:glob,代碼行數:42,代碼來源:AbstractTraversalFinder.php

示例5: getUrl

    /**
     * Gets a relative filesystem path based on the repository path, AND
     * creates the file on the filesystem if it's in the repository
     * and not yet on the filesystem.
     * The repository path points to a nt-resource node, whose title
     * should be the filename, and which has a child+property
     * jcr:content/jcr:data where the file data is stored.
     *
     * @param string $path path to the nt-resource node.
     * @return string with a path to the file, relative to the web directory.
     */
    public function getUrl(NodeInterface $node)
    {

        $hasData = false;
        if ($node->hasNode('jcr:content')) {
            $contentNode = $node->getNode('jcr:content');
            if ($contentNode->hasProperty('jcr:data')) {
                $hasData = true;
            }
        }
        if (!$hasData) {
            //TODO: notfound exception is not appropriate ... how to best do this?
            //throw new NotFoundHttpException('no picture found at ' . $node->getPath());
            return 'notfound';
        }

        $path = $node->getPath();
        $relativePath = $this->pathMapper->getUrl($path);
        $fullPath = $this->fileBasePath . $relativePath . $this->getExtension($contentNode);

        if (!file_exists($fullPath)) {
            try {
                $this->saveData($contentNode, $fullPath);
            } catch (Imagine\Exception\Exception $e) {
                //TODO: notfound exception is not appropriate ... how to best do this?
                //throw new NotFoundHttpException('image save to filesystem failed: ' . $e->getMessage());
                return 'notfound';
            }
        }

        return $this->webRelativePath . $relativePath . $this->getExtension($contentNode);
    }
開發者ID:ralf57,項目名稱:CoreBundle,代碼行數:43,代碼來源:RepositoryFileHelper.php

示例6: getUrl

 /**
  * Gets a relative filesystem path based on the repository path, AND
  * creates the file on the filesystem if it's in the repository
  * and not yet on the filesystem.
  * The repository path points to a nt-resource node, whose title
  * should be the filename, and which has a child+property
  * jcr:content/jcr:data where the file data is stored.
  *
  * @param string $path path to the nt-resource node.
  * @return string with a path to the file, relative to the web directory.
  */
 public function getUrl(NodeInterface $node)
 {
     $hasData = false;
     if ($node->hasNode('jcr:content')) {
         $contentNode = $node->getNode('jcr:content');
         if ($contentNode->hasProperty('jcr:data')) {
             $hasData = true;
         }
     }
     if (!$hasData) {
         //TODO: notfound exception is not appropriate ... how to best do this?
         //throw new NotFoundHttpException('no picture found at ' . $node->getPath());
         return 'notfound';
     }
     $path = $node->getPath();
     $relativePath = $this->pathMapper->getUrl($path);
     $extension = $this->getExtension($contentNode);
     $fullPath = $this->fileBasePath . '/' . $relativePath . $extension;
     if (!file_exists($fullPath)) {
         if (!$this->saveData($contentNode, $fullPath)) {
             throw new FileException('failed to save data to file: ' . $fullPath);
         }
     }
     return $this->webRelativePath . '/' . $relativePath . $extension;
 }
開發者ID:richardmiller,項目名稱:symfony-cmf,代碼行數:36,代碼來源:RepositoryFileHelper.php

示例7: transform

 /**
  * Transform a node into a path.
  *
  * @param \PHPCR\NodeInterface|null $node
  *
  * @return string|null the path to the node or null if $node is null
  *
  * @throws UnexpectedTypeException if given value is not a \PHPCR\NodeInterface
  */
 public function transform($node)
 {
     if (null === $node) {
         return;
     }
     if (!$node instanceof NodeInterface) {
         throw new UnexpectedTypeException($node, 'PHPCR\\NodeInterface');
     }
     return $node->getPath();
 }
開發者ID:xabbuh,項目名稱:DoctrinePHPCRBundle,代碼行數:19,代碼來源:PHPCRNodeToPathTransformer.php

示例8: it_should_provide_a_method_to_determine_if_a_node_is_versionable

 public function it_should_provide_a_method_to_determine_if_a_node_is_versionable(NodeInterface $nodeVersionable, NodeInterface $nodeNotVersionable, NodeTypeInterface $mixin1, NodeTypeInterface $mixin2)
 {
     $nodeVersionable->getMixinNodeTypes()->willReturn(array($mixin1, $mixin2));
     $nodeNotVersionable->getMixinNodeTypes()->willReturn(array($mixin2));
     $nodeNotVersionable->getPath()->willReturn('foobar');
     $mixin1->getName()->willReturn('mix:versionable');
     $this->assertNodeIsVersionable($nodeVersionable)->shouldReturn(null);
     try {
         $this->assertNodeIsVersionable($nodeNotVersionable);
     } catch (\OutOfBoundsException $e) {
     }
 }
開發者ID:hason,項目名稱:phpcr-shell,代碼行數:12,代碼來源:NodeHelperSpec.php

示例9: testFlushNullableFieldNotSetUpdate

 public function testFlushNullableFieldNotSetUpdate()
 {
     $doc = new Article();
     $doc->id = $this->node->getPath() . '/flush';
     $doc->topic = 'title';
     $doc->text = 'text';
     $doc->locale = 'en';
     $this->dm->persist($doc);
     $this->dm->flush();
     $this->setExpectedException('Doctrine\\ODM\\PHPCR\\PHPCRException');
     $doc->topic = null;
     $this->dm->flush();
 }
開發者ID:steffenbrem,項目名稱:phpcr-odm,代碼行數:13,代碼來源:DocumentManagerTest.php

示例10: getClassName

 /**
  * {@inheritDoc}
  */
 public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, $className = null)
 {
     $className = $this->expandClassName($dm, $className);
     if ($node->hasProperty('phpcr:class')) {
         $nodeClassName = $node->getProperty('phpcr:class')->getString();
         if (!empty($className) && $nodeClassName !== $className && !is_subclass_of($nodeClassName, $className)) {
             throw ClassMismatchException::incompatibleClasses($node->getPath(), $nodeClassName, $className);
         }
         $className = $nodeClassName;
     }
     // default to the built in generic document class
     if (empty($className)) {
         $className = 'Doctrine\\ODM\\PHPCR\\Document\\Generic';
     }
     return $className;
 }
開發者ID:steffenbrem,項目名稱:phpcr-odm,代碼行數:19,代碼來源:DocumentClassMapper.php

示例11: resolveSiblingName

 private function resolveSiblingName($siblingId, NodeInterface $parentNode, NodeInterface $node)
 {
     if (null === $siblingId) {
         return;
     }
     $siblingPath = $siblingId;
     if (UUIDHelper::isUUID($siblingId)) {
         $siblingPath = $this->nodeManager->find($siblingId)->getPath();
     }
     if ($siblingPath !== null && PathHelper::getParentPath($siblingPath) !== $parentNode->getPath()) {
         throw new DocumentManagerException(sprintf('Cannot reorder documents which are not siblings. Trying to reorder "%s" to "%s"', $node->getPath(), $siblingPath));
     }
     if (null !== $siblingPath) {
         return PathHelper::getNodeName($siblingPath);
     }
     return $node->getName();
 }
開發者ID:hason,項目名稱:sulu-document-manager,代碼行數:17,代碼來源:ReorderSubscriber.php

示例12: nodeToArray

 /**
  *
  * Returns an array representation of a PHPCR node
  *
  * @param string $name
  * @param \PHPCR\NodeInterface $node
  *
  * @return array
  */
 private function nodeToArray($name, $node)
 {
     $has_children = $node->hasNodes();
     return array('data' => $name, 'attr' => array('id' => $node->getPath(), 'url_safe_id' => substr($node->getPath(), 1), 'rel' => 'node'), 'state' => $has_children ? 'closed' : null);
 }
開發者ID:EmmanuelVella,項目名稱:TreeBrowserBundle,代碼行數:14,代碼來源:PHPCRTree.php

示例13: loadShallowStructureByNode

 /**
  * Load/hydrate a shalow structure with the given node.
  * Shallow structures do not have content properties / extensions
  * hydrated.
  *
  * @param NodeInterface $node
  * @param string        $localization
  * @param string        $webspaceKey
  *
  * @return StructureInterface
  */
 public function loadShallowStructureByNode(NodeInterface $contentNode, $localization, $webspaceKey)
 {
     $document = $this->documentManager->find($contentNode->getPath(), $localization);
     return $this->documentToStructure($document);
 }
開發者ID:kriswillis,項目名稱:sulu,代碼行數:16,代碼來源:ContentMapper.php

示例14: filterChildNodeNamesByType

 /**
  * This method will either let the transport filter if that is possible or
  * forward to getNodes and return the names of the nodes found there.,
  *
  * @param NodeInterface $node
  * @param string|array  $nameFilter
  * @param string|array  $typeFilter
  *
  * @return ArrayIterator
  */
 public function filterChildNodeNamesByType(NodeInterface $node, $nameFilter, $typeFilter)
 {
     if ($this->transport instanceof NodeTypeFilterInterface) {
         return $this->transport->filterChildNodeNamesByType($node->getPath(), $node->getNodeNames($nameFilter), $typeFilter);
     }
     // fallback: get the actual nodes and let that filter. this is expensive.
     return new ArrayIterator(array_keys($node->getNodes($nameFilter, $typeFilter)->getArrayCopy()));
 }
開發者ID:nikophil,項目名稱:cmf-tests,代碼行數:18,代碼來源:ObjectManager.php

示例15: getSiblingNode

 /**
  * Return either the next or previous sibling of the given node
  * according to the $previous flag.
  *
  * @param NodeInterface $node
  * @param bool          $previous
  *
  * @return NodeInterface|null
  *
  * @throws \RuntimeException
  */
 private function getSiblingNode(NodeInterface $node, $previous = false)
 {
     $parentNode = $node->getParent();
     $children = $parentNode->getNodes();
     $previousNode = null;
     while ($child = current($children)) {
         if ($child->getPath() === $node->getPath()) {
             return $previous ? $previousNode : next($children);
         }
         $previousNode = $child;
         next($children);
     }
     throw new \RuntimeException(sprintf('Could not find node with path "%s" as a child of "%s". This should not happen', $node->getPath(), $parentNode->getPath()));
 }
開發者ID:sulu,項目名稱:sulu,代碼行數:25,代碼來源:SuluNodeHelper.php


注:本文中的PHPCR\NodeInterface::getPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。