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


PHP Context::getNodeByIdentifier方法代码示例

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


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

示例1: getProperty

 /**
  * Returns the specified property.
  *
  * If the node has a content object attached, the property will be fetched
  * there if it is gettable.
  *
  * @param string $propertyName Name of the property
  * @param boolean $returnNodesAsIdentifiers If enabled, references to nodes are returned as node identifiers instead of NodeData objects
  * @return mixed value of the property
  * @api
  */
 public function getProperty($propertyName, $returnNodesAsIdentifiers = false)
 {
     $value = $this->nodeData->getProperty($propertyName);
     if (!empty($value)) {
         $nodeType = $this->getNodeType();
         if ($nodeType->hasConfiguration('properties.' . $propertyName)) {
             $expectedPropertyType = $nodeType->getPropertyType($propertyName);
             switch ($expectedPropertyType) {
                 case 'references':
                     if ($returnNodesAsIdentifiers === false) {
                         $nodes = array();
                         foreach ($value as $nodeIdentifier) {
                             $node = $this->context->getNodeByIdentifier($nodeIdentifier);
                             // $node can be NULL if the node is not visible according to the current content context:
                             if ($node !== null) {
                                 $nodes[] = $node;
                             }
                         }
                         $value = $nodes;
                     }
                     break;
                 case 'reference':
                     if ($returnNodesAsIdentifiers === false) {
                         $value = $this->context->getNodeByIdentifier($value);
                     }
                     break;
                 default:
                     $value = $this->propertyMapper->convert($value, $expectedPropertyType);
                     break;
             }
         }
     }
     return $value;
 }
开发者ID:rderidder,项目名称:neos-development-collection,代码行数:45,代码来源:Node.php

示例2: resolvePropertyReferences

 /**
  * Maps the property value (an array of node identifiers) to the Node objects if needed.
  *
  * @param array $value
  * @return array
  */
 protected function resolvePropertyReferences($value = [])
 {
     $nodes = array_map(function ($nodeIdentifier) {
         return $this->context->getNodeByIdentifier($nodeIdentifier);
     }, $value);
     return array_filter($nodes);
 }
开发者ID:hhoechtl,项目名称:neos-development-collection,代码行数:13,代码来源:Node.php

示例3: setNodeProperties

 /**
  * Iterates through the given $properties setting them on the specified $node using the appropriate TypeConverters.
  *
  * @param object $nodeLike
  * @param NodeType $nodeType
  * @param array $properties
  * @param TYPO3CRContext $context
  * @param PropertyMappingConfigurationInterface $configuration
  * @return void
  * @throws TypeConverterException
  */
 protected function setNodeProperties($nodeLike, NodeType $nodeType, array $properties, TYPO3CRContext $context, PropertyMappingConfigurationInterface $configuration = null)
 {
     $nodeTypeProperties = $nodeType->getProperties();
     unset($properties['_lastPublicationDateTime']);
     foreach ($properties as $nodePropertyName => $nodePropertyValue) {
         if (substr($nodePropertyName, 0, 2) === '__') {
             continue;
         }
         $nodePropertyType = isset($nodeTypeProperties[$nodePropertyName]['type']) ? $nodeTypeProperties[$nodePropertyName]['type'] : null;
         switch ($nodePropertyType) {
             case 'reference':
                 $nodePropertyValue = $context->getNodeByIdentifier($nodePropertyValue);
                 break;
             case 'references':
                 $nodeIdentifiers = json_decode($nodePropertyValue);
                 $nodePropertyValue = array();
                 if (is_array($nodeIdentifiers)) {
                     foreach ($nodeIdentifiers as $nodeIdentifier) {
                         $referencedNode = $context->getNodeByIdentifier($nodeIdentifier);
                         if ($referencedNode !== null) {
                             $nodePropertyValue[] = $referencedNode;
                         }
                     }
                 } elseif ($nodeIdentifiers !== null) {
                     throw new TypeConverterException(sprintf('node type "%s" expects an array of identifiers for its property "%s"', $nodeType->getName(), $nodePropertyName), 1383587419);
                 }
                 break;
             case 'DateTime':
                 if ($nodePropertyValue !== '' && ($nodePropertyValue = \DateTime::createFromFormat(\DateTime::W3C, $nodePropertyValue)) !== false) {
                     $nodePropertyValue->setTimezone(new \DateTimeZone(date_default_timezone_get()));
                 } else {
                     $nodePropertyValue = null;
                 }
                 break;
             case 'integer':
                 $nodePropertyValue = intval($nodePropertyValue);
                 break;
             case 'boolean':
                 if (is_string($nodePropertyValue)) {
                     $nodePropertyValue = $nodePropertyValue === 'true' ? true : false;
                 }
                 break;
             case 'array':
                 $nodePropertyValue = json_decode($nodePropertyValue, true);
                 break;
         }
         if (substr($nodePropertyName, 0, 1) === '_') {
             $nodePropertyName = substr($nodePropertyName, 1);
             ObjectAccess::setProperty($nodeLike, $nodePropertyName, $nodePropertyValue);
             continue;
         }
         if (!isset($nodeTypeProperties[$nodePropertyName])) {
             if ($configuration !== null && $configuration->shouldSkipUnknownProperties()) {
                 continue;
             } else {
                 throw new TypeConverterException(sprintf('Node type "%s" does not have a property "%s" according to the schema', $nodeType->getName(), $nodePropertyName), 1359552744);
             }
         }
         $innerType = $nodePropertyType;
         if ($nodePropertyType !== null) {
             try {
                 $parsedType = TypeHandling::parseType($nodePropertyType);
                 $innerType = $parsedType['elementType'] ?: $parsedType['type'];
             } catch (InvalidTypeException $exception) {
             }
         }
         if (is_string($nodePropertyValue) && $this->objectManager->isRegistered($innerType) && $nodePropertyValue !== '') {
             $nodePropertyValue = $this->propertyMapper->convert(json_decode($nodePropertyValue, true), $nodePropertyType, $configuration);
         }
         $nodeLike->setProperty($nodePropertyName, $nodePropertyValue);
     }
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:83,代码来源:NodeConverter.php

示例4: getPersonProfile

 /**
  * @param string $personIdentifier
  * @param Context $context
  *
  * @throws \Exception
  *
  * @return NodeInterface
  */
 protected function getPersonProfile($personIdentifier, Context $context)
 {
     if ($personIdentifier === '') {
         $person = $this->profileService->getCurrentPartyProfile();
     } else {
         $person = $context->getNodeByIdentifier($personIdentifier);
     }
     return $person;
 }
开发者ID:keen-vantage,项目名称:BJD.Events,代码行数:17,代码来源:EventController.php

示例5: setNodeProperties

 /**
  * Iterates through the given $properties setting them on the specified $node using the appropriate TypeConverters.
  *
  * @param object $nodeLike
  * @param NodeType $nodeType
  * @param array $properties
  * @param \TYPO3\TYPO3CR\Domain\Service\Context $context
  * @throws \TYPO3\Flow\Property\Exception\TypeConverterException
  * @return void
  */
 protected function setNodeProperties($nodeLike, NodeType $nodeType, array $properties, TYPO3CRContext $context)
 {
     $nodeTypeProperties = $nodeType->getProperties();
     foreach ($properties as $nodePropertyName => $nodePropertyValue) {
         if (substr($nodePropertyName, 0, 2) === '__') {
             continue;
         }
         $nodePropertyType = isset($nodeTypeProperties[$nodePropertyName]['type']) ? $nodeTypeProperties[$nodePropertyName]['type'] : NULL;
         switch ($nodePropertyType) {
             case 'reference':
                 $nodePropertyValue = $context->getNodeByIdentifier($nodePropertyValue);
                 break;
             case 'references':
                 $nodeIdentifiers = json_decode($nodePropertyValue);
                 $nodePropertyValue = array();
                 if (is_array($nodeIdentifiers)) {
                     foreach ($nodeIdentifiers as $nodeIdentifier) {
                         $referencedNode = $context->getNodeByIdentifier($nodeIdentifier);
                         if ($referencedNode !== NULL) {
                             $nodePropertyValue[] = $referencedNode;
                         }
                     }
                 } else {
                     throw new TypeConverterException(sprintf('node type "%s" expects an array of identifiers for its property "%s"', $nodeType->getName(), $nodePropertyName), 1383587419);
                 }
                 break;
             case 'date':
                 if ($nodePropertyValue !== '') {
                     $nodePropertyValue = \DateTime::createFromFormat('!Y-m-d', $nodePropertyValue);
                 } else {
                     $nodePropertyValue = NULL;
                 }
                 break;
         }
         if (substr($nodePropertyName, 0, 1) === '_') {
             $nodePropertyName = substr($nodePropertyName, 1);
             ObjectAccess::setProperty($nodeLike, $nodePropertyName, $nodePropertyValue);
             continue;
         }
         if (!isset($nodeTypeProperties[$nodePropertyName])) {
             throw new TypeConverterException(sprintf('node type "%s" does not have a property "%s" according to the schema', $nodeType->getName(), $nodePropertyName), 1359552744);
         }
         if ($this->objectManager->isRegistered($nodePropertyType) && $nodePropertyValue !== '') {
             $nodePropertyValue = $this->propertyMapper->convert(json_decode($nodePropertyValue, TRUE), $nodePropertyType);
         }
         $nodeLike->setProperty($nodePropertyName, $nodePropertyValue);
     }
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:58,代码来源:NodeConverter.php

示例6: convertReferences

 /**
  * Convert raw value to references
  *
  * @param string $rawValue
  * @param Context $context
  * @return array<NodeInterface>
  */
 protected function convertReferences($rawValue, Context $context)
 {
     $nodeIdentifiers = json_decode($rawValue);
     $result = [];
     if (is_array($nodeIdentifiers)) {
         foreach ($nodeIdentifiers as $nodeIdentifier) {
             $referencedNode = $context->getNodeByIdentifier($nodeIdentifier);
             if ($referencedNode !== null) {
                 $result[] = $referencedNode;
             }
         }
     }
     return $result;
 }
开发者ID:neos,项目名称:neos-ui,代码行数:21,代码来源:NodePropertyConversionService.php


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