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


PHP PHPCR\NodeInterface类代码示例

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


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

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

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

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

示例4: remove

 /**
  * {@inheritdoc}
  */
 public function remove(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     // if exist remove property of node
     if ($node->hasProperty($property->getName())) {
         $node->getProperty($property->getName())->remove();
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:10,代码来源:SimpleContentType.php

示例5: serializePhpcrNode

 /**
  * @param JsonSerializationVisitor $visitor
  * @param NodeInterface            $nodeInterface
  * @param array                    $type
  * @param Context                  $context
  */
 public function serializePhpcrNode(JsonSerializationVisitor $visitor, NodeInterface $node, array $type, Context $context)
 {
     $res = array();
     foreach ($node->getProperties() as $name => $property) {
         $res[$name] = $property->getValue();
     }
     return $res;
 }
开发者ID:frogriotcom,项目名称:ResourceRestBundle,代码行数:14,代码来源:PhpcrNodeHandler.php

示例6: saveData

 /**
  *
  *
  * @param NodeInterface $contentNode
  * @param string $filesystemPath
  * @return Boolean
  */
 protected function saveData($contentNode, $filesystemPath)
 {
     $data = $contentNode->getProperty('jcr:data')->getString();
     $dirname = dirname($filesystemPath);
     if (!file_exists($dirname)) {
         mkdir($dirname, 0755, true);
     }
     return file_put_contents($filesystemPath, $data);
 }
开发者ID:richardmiller,项目名称:symfony-cmf,代码行数:16,代码来源:RepositoryFileHelper.php

示例7: upgradeNode

 /**
  * Removes non translated properties.
  *
  * @param NodeInterface $node
  */
 private function upgradeNode(NodeInterface $node)
 {
     foreach ($node->getProperties('i18n:-*') as $property) {
         $property->remove();
     }
     foreach ($node->getNodes() as $childNode) {
         $this->upgradeNode($childNode);
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:14,代码来源:Version201512090753.php

示例8: writeMetadata

 /**
  * {@inheritDoc}
  */
 public function writeMetadata(DocumentManagerInterface $dm, NodeInterface $node, $className)
 {
     $className = $this->expandClassName($dm, $className);
     if ('Doctrine\\ODM\\PHPCR\\Document\\Generic' !== $className) {
         $node->setProperty('phpcr:class', $className, PropertyType::STRING);
         $class = $dm->getClassMetadata($className);
         $node->setProperty('phpcr:classparents', $class->getParentClasses(), PropertyType::STRING);
     }
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:12,代码来源:DocumentClassMapper.php

示例9: write

 /**
  * {@inheritdoc}
  */
 public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = $property->getValue();
     if ($value !== null) {
         $node->setProperty($property->getName(), $this->removeValidation($this->removeIllegalCharacters($value)));
     } else {
         $this->remove($node, $property, $webspaceKey, $languageCode, $segmentKey);
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:12,代码来源:TextEditor.php

示例10: write

 /**
  * {@inheritdoc}
  */
 public function write(NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = $property->getValue();
     if ($value !== null && $value !== false && $value !== 'false' && $value !== '') {
         $node->setProperty($property->getName(), true);
     } else {
         $node->setProperty($property->getName(), false);
     }
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:12,代码来源:Checkbox.php

示例11: createNodes

 protected function createNodes(NodeInterface $parentNode, $number, $properties = array(), $offset = 0)
 {
     $number = $number + $offset;
     for ($i = $offset; $i < $number; $i++) {
         $node = $parentNode->addNode('node-' . $i);
         foreach ($properties as $property => $value) {
             $node->setProperty($property, $value);
         }
     }
 }
开发者ID:phpcr,项目名称:phpcr-benchmarks,代码行数:10,代码来源:BaseBench.php

示例12: traverse

 private function traverse(NodeInterface $node)
 {
     $i = 10;
     foreach ($node->getNodes() as $childNode) {
         $childNode->setProperty(NodeOrderSubscriber::SULU_ORDER, $i);
         $this->context->getOutput()->writeln(sprintf('<info>[+]</info> Setting order "<comment>%s</comment>" on <comment>%s</comment>', $i, $childNode->getPath()));
         $this->traverse($childNode);
         $i += 10;
     }
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:10,代码来源:NodeOrderBuilder.php

示例13: transform

 /**
  * Transform a node into a uuid
  *
  * @param \PHPCR\NodeInterface|null $node
  *
  * @return string|null the uuid 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 null;
     }
     if (!$node instanceof NodeInterface) {
         throw new UnexpectedTypeException($node, 'PHPCR\\NodeInterface');
     }
     return $node->getIdentifier();
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:19,代码来源:PHPCRNodeToUuidTransformer.php

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

示例15: read

 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = '';
     if ($node->hasProperty($property->getName())) {
         /** @var \DateTime $propertyValue */
         $propertyValue = $node->getPropertyValue($property->getName());
         $value = $propertyValue->format('Y-m-d');
     }
     $property->setValue($value);
     return $value;
 }
开发者ID:ollietb,项目名称:sulu,代码行数:14,代码来源:Date.php


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