当前位置: 首页>>代码示例>>PHP>>正文


PHP NodeInterface::hasNode方法代码示例

本文整理汇总了PHP中PHPCR\NodeInterface::hasNode方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::hasNode方法的具体用法?PHP NodeInterface::hasNode怎么用?PHP NodeInterface::hasNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPCR\NodeInterface的用法示例。


在下文中一共展示了NodeInterface::hasNode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRemove3

 /**
  * Remove the parent node of multiple child level
  */
 public function testRemove3()
 {
     $parent = new ChildTestObj();
     $parent->name = 'Parent';
     $parent->id = '/functional/childtest';
     // Lv1
     $childLv1 = new ChildReferenceableTestObj();
     $childLv1->name = 'Child-Lv1';
     $parent->child = $childLv1;
     // Lv2
     $childLv2 = new ChildChildTestObj();
     $childLv2->name = 'Child-Lv2';
     $childLv1->aChild = $childLv2;
     $this->dm->persist($parent);
     $this->dm->flush();
     $this->dm->clear();
     $parent = $this->dm->find($this->type, '/functional/childtest');
     $this->assertTrue($this->node->hasNode('childtest'));
     $this->assertTrue($this->node->getNode('childtest')->hasNode('test'));
     $this->assertTrue($this->node->getNode('childtest')->getNode('test')->hasNode('test'));
     $this->dm->remove($parent);
     $this->dm->flush();
     $this->dm->clear();
     $parent = $this->dm->find($this->type, '/functional/childtest');
     $this->assertNull($parent);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:29,代码来源:ChildTest.php

示例2: 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

示例3: resolveName

 /**
  * @param NodeInterface $parentNode
  * @param string $name
  * @param null|NodeInterface $forNode
  *
  * @return string
  */
 public function resolveName(NodeInterface $parentNode, $name, $forNode = null)
 {
     if ($forNode && $parentNode->hasNode($name) && $parentNode->getNode($name) == $forNode) {
         return $name;
     }
     $index = 0;
     $baseName = $name;
     do {
         if ($index > 0) {
             $name = $baseName . '-' . $index;
         }
         $hasChild = $parentNode->hasNode($name);
         ++$index;
     } while ($hasChild);
     return $name;
 }
开发者ID:hason,项目名称:sulu-document-manager,代码行数:23,代码来源:NameResolver.php

示例4: 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

示例5: getTranslationNode

 protected function getTranslationNode(NodeInterface $parentNode, $locale)
 {
     $name = Translation::LOCALE_NAMESPACE . ":{$locale}";
     if (!$parentNode->hasNode($name)) {
         $node = $parentNode->addNode($name);
     } else {
         $node = $parentNode->getNode($name);
     }
     return $node;
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:10,代码来源:ChildTranslationStrategy.php

示例6: assertFolderAndFile

 /**
  * Assert that $node has a folder child that is an nt:folder and has a
  * child * called file that is an nt:file.
  *
  * @param NodeInterface $node
  */
 private function assertFolderAndFile(NodeInterface $node)
 {
     $this->assertTrue($node->hasNode('folder'));
     $folder = $node->getNode('folder');
     $this->assertTrue($folder->hasProperty('jcr:created'));
     $this->assertInstanceOf('\\DateTime', $folder->getPropertyValue('jcr:created'));
     $this->assertTrue($folder->hasNode('file'));
     $file = $folder->getNode('file');
     $this->assertTrue($file->hasNode('jcr:content'));
     $resource = $file->getNode('jcr:content');
     $this->assertTrue($resource->hasProperty('jcr:lastModified'));
     $this->assertInstanceOf('\\DateTime', $resource->getPropertyValue('jcr:lastModified'));
     $this->assertTrue($resource->hasProperty('jcr:data'));
     $binaryStream = $file->getNode('jcr:content')->getProperty('jcr:data')->getBinary();
     $this->assertNotNull($binaryStream, 'We got no content from the file');
     $content = stream_get_contents($binaryStream);
     $this->assertEquals(self::FILE_CONTENT, $content);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:24,代码来源:FolderFileTest.php

示例7: isUnique

 /**
  * check if path is unique from given $root node.
  *
  * @param NodeInterface $root route node
  * @param string        $path requested path
  *
  * @return bool path is unique
  */
 private function isUnique(NodeInterface $root, $path)
 {
     // check if root has node
     return !$root->hasNode(ltrim($path, '/'));
 }
开发者ID:ollietb,项目名称:sulu,代码行数:13,代码来源:PhpcrMapper.php

示例8: getUniquePath

 /**
  * @param $name
  * @param NodeInterface $parent
  *
  * @return string
  */
 private function getUniquePath($name, NodeInterface $parent)
 {
     if ($parent->hasNode($name)) {
         $i = 0;
         do {
             $i++;
         } while ($parent->hasNode($name . '-' . $i));
         return $name . '-' . $i;
     } else {
         return $name;
     }
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:18,代码来源:ContentMapper.php

示例9: hasNode

 /**
  * {@inheritdoc}
  */
 public function hasNode($relPath)
 {
     return $this->node->hasNode($relPath);
 }
开发者ID:sulu,项目名称:sulu,代码行数:7,代码来源:SuluNode.php

示例10: processNodeWithType

 /**
  * Validate this node with the nodetype and generate not yet existing
  * autogenerated properties as necessary.
  *
  * @param NodeInterface $node
  * @param NodeType      $nodeTypeDefinition
  *
  * @return AddNodeOperation[] Additional operations to handle autocreated nodes.
  *
  * @throws \InvalidArgumentException
  * @throws RepositoryException
  * @throws ItemExistsException
  * @throws LockException
  * @throws ConstraintViolationException
  * @throws PathNotFoundException
  * @throws VersionException
  * @throws ValueFormatException
  */
 private function processNodeWithType(NodeInterface $node, NodeType $nodeTypeDefinition)
 {
     $additionalOperations = array();
     foreach ($nodeTypeDefinition->getDeclaredChildNodeDefinitions() as $childDef) {
         /* @var $childDef NodeDefinitionInterface */
         if (!$node->hasNode($childDef->getName())) {
             if ('*' === $childDef->getName()) {
                 continue;
             }
             if ($childDef->isMandatory() && !$childDef->isAutoCreated()) {
                 throw new RepositoryException(sprintf('Child "%s" is mandatory, but is not present while saving "%s" at path "%s"', $childDef->getName(), $nodeTypeDefinition->getName(), $node->getPath()));
             }
             if ($childDef->isAutoCreated()) {
                 $requiredPrimaryTypeNames = $childDef->getRequiredPrimaryTypeNames();
                 $primaryType = count($requiredPrimaryTypeNames) ? current($requiredPrimaryTypeNames) : null;
                 $newNode = $node->addNode($childDef->getName(), $primaryType);
                 $absPath = $node->getPath() . '/' . $childDef->getName();
                 $operation = new AddNodeOperation($absPath, $newNode);
                 $additionalOperations[] = $operation;
             }
         }
     }
     foreach ($nodeTypeDefinition->getDeclaredPropertyDefinitions() as $propertyDef) {
         /* @var $propertyDef PropertyDefinitionInterface */
         if ('*' === $propertyDef->getName()) {
             continue;
         }
         if (!$node->hasProperty($propertyDef->getName())) {
             if ($propertyDef->isMandatory() && !$propertyDef->isAutoCreated()) {
                 throw new RepositoryException(sprintf('Property "%s" is mandatory, but is not present while saving "%s" at "%s"', $propertyDef->getName(), $nodeTypeDefinition->getName(), $node->getPath()));
             }
             if ($propertyDef->isAutoCreated()) {
                 switch ($propertyDef->getName()) {
                     case 'jcr:uuid':
                         $value = UUIDHelper::generateUUID();
                         break;
                     case 'jcr:createdBy':
                     case 'jcr:lastModifiedBy':
                         $value = $this->userId;
                         break;
                     case 'jcr:created':
                     case 'jcr:lastModified':
                         $value = new \DateTime();
                         break;
                     case 'jcr:etag':
                         // TODO: http://www.day.com/specs/jcr/2.0/3_Repository_Model.html#3.7.12.1%20mix:etag
                         $value = 'TODO: generate from binary properties of this node';
                         break;
                     default:
                         $defaultValues = $propertyDef->getDefaultValues();
                         if ($propertyDef->isMultiple()) {
                             $value = $defaultValues;
                         } elseif (isset($defaultValues[0])) {
                             $value = $defaultValues[0];
                         } else {
                             // When implementing versionable or activity, we need to handle more properties explicitly
                             throw new RepositoryException(sprintf('No default value for autocreated property "%s" at "%s"', $propertyDef->getName(), $node->getPath()));
                         }
                 }
                 $node->setProperty($propertyDef->getName(), $value, $propertyDef->getRequiredType());
             }
         } elseif ($propertyDef->isAutoCreated()) {
             $prop = $node->getProperty($propertyDef->getName());
             if (!$prop->isModified() && !$prop->isNew()) {
                 switch ($propertyDef->getName()) {
                     case 'jcr:lastModified':
                         if ($this->autoLastModified) {
                             $prop->setValue(new \DateTime());
                         }
                         break;
                     case 'jcr:lastModifiedBy':
                         if ($this->autoLastModified) {
                             $prop->setValue($this->userId);
                         }
                         break;
                     case 'jcr:etag':
                         // TODO: update etag if needed
                         break;
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:jackalope,项目名称:jackalope,代码行数:101,代码来源:NodeProcessor.php

示例11: testHasNodeFalse

 public function testHasNodeFalse()
 {
     $this->assertFalse($this->node->hasNode('foobar'));
 }
开发者ID:laurentiuc,项目名称:phpcr-api-tests,代码行数:4,代码来源:NodeReadMethodsTest.php


注:本文中的PHPCR\NodeInterface::hasNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。