当前位置: 首页>>代码示例>>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;未经允许,请勿转载。