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


PHP Context::getDimensions方法代码示例

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


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

示例1: findNodesByPropertyKeyAndValue

 /**
  * @test
  */
 public function findNodesByPropertyKeyAndValue()
 {
     $this->createNodesForNodeSearchTest();
     $result = $this->nodeDataRepository->findByProperties(array('test2' => 'simpleTestValue'), 'TYPO3.TYPO3CR.Testing:NodeType', $this->liveWorkspace, $this->context->getDimensions());
     $this->assertCount(1, $result);
     $this->assertEquals('test-node-2', array_shift($result)->getName());
 }
开发者ID:hhoechtl,项目名称:neos-development-collection,代码行数:10,代码来源:NodeDataRepositoryTest.php

示例2: dimensionsAreMatchingTargetDimensionValues

 /**
  * Internal method
  *
  * The dimension value of this node has to match the current target dimension value (must be higher in priority or equal)
  *
  * @return boolean
  */
 public function dimensionsAreMatchingTargetDimensionValues()
 {
     $dimensions = $this->getDimensions();
     $contextDimensions = $this->context->getDimensions();
     foreach ($this->context->getTargetDimensions() as $dimensionName => $targetDimensionValue) {
         if (!isset($dimensions[$dimensionName])) {
             if ($targetDimensionValue === null) {
                 continue;
             } else {
                 return false;
             }
         } elseif ($targetDimensionValue === null && $dimensions[$dimensionName] === array()) {
             continue;
         } elseif (!in_array($targetDimensionValue, $dimensions[$dimensionName], true)) {
             $contextDimensionValues = $contextDimensions[$dimensionName];
             $targetPositionInContext = array_search($targetDimensionValue, $contextDimensionValues, true);
             $nodePositionInContext = min(array_map(function ($value) use($contextDimensionValues) {
                 return array_search($value, $contextDimensionValues, true);
             }, $dimensions[$dimensionName]));
             $val = $targetPositionInContext !== false && $nodePositionInContext !== false && $targetPositionInContext >= $nodePositionInContext;
             if ($val === false) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:hhoechtl,项目名称:neos-development-collection,代码行数:34,代码来源:Node.php

示例3: findByProperties

 /**
  * Search all properties for given $term
  *
  * TODO: Implement a better search when Flow offer the possibility
  *
  * @param string $term
  * @param array $searchNodeTypes
  * @param Context $context
  * @param NodeInterface $startingPoint
  * @return array <\TYPO3\TYPO3CR\Domain\Model\NodeInterface>
  */
 public function findByProperties($term, array $searchNodeTypes, Context $context, NodeInterface $startingPoint = null)
 {
     if (strlen($term) === 0) {
         throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285);
     }
     $searchResult = array();
     $nodeTypeFilter = implode(',', $searchNodeTypes);
     $nodeDataRecords = $this->nodeDataRepository->findByProperties($term, $nodeTypeFilter, $context->getWorkspace(), $context->getDimensions(), $startingPoint ? $startingPoint->getPath() : null);
     foreach ($nodeDataRecords as $nodeData) {
         $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
         if ($node !== null) {
             $searchResult[$node->getPath()] = $node;
         }
     }
     return $searchResult;
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:27,代码来源:NodeSearchService.php

示例4: dimensionsAreMatchingTargetDimensionValues

 /**
  * The dimension value of this node has to match the current target dimension value (must be higher in priority or equal)
  *
  * @return boolean
  */
 protected function dimensionsAreMatchingTargetDimensionValues()
 {
     $dimensions = $this->getDimensions();
     $contextDimensions = $this->context->getDimensions();
     foreach ($this->context->getTargetDimensions() as $dimensionName => $targetDimensionValue) {
         if (!isset($dimensions[$dimensionName])) {
             return FALSE;
         } elseif (!in_array($targetDimensionValue, $dimensions[$dimensionName], TRUE)) {
             $contextDimensionValues = $contextDimensions[$dimensionName];
             $targetPositionInContext = array_search($targetDimensionValue, $contextDimensionValues, TRUE);
             $nodePositionInContext = min(array_map(function ($value) use($contextDimensionValues) {
                 return array_search($value, $contextDimensionValues, TRUE);
             }, $dimensions[$dimensionName]));
             $val = $targetPositionInContext !== FALSE && $nodePositionInContext !== FALSE && $targetPositionInContext >= $nodePositionInContext;
             if ($val === FALSE) {
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:26,代码来源:Node.php

示例5: 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
  * @param \TYPO3\TYPO3CR\Domain\Service\Context $context An optional Context if $returnNodesAsIdentifiers === TRUE
  * @return mixed value of the property
  * @throws \TYPO3\TYPO3CR\Exception\NodeException if the content object exists but does not contain the specified property.
  */
 public function getProperty($propertyName, $returnNodesAsIdentifiers = FALSE, \TYPO3\TYPO3CR\Domain\Service\Context $context = NULL)
 {
     if (!is_object($this->contentObjectProxy)) {
         $value = isset($this->properties[$propertyName]) ? $this->properties[$propertyName] : NULL;
         if (!empty($value)) {
             // TODO: The next two lines are workarounds, actually a NodeData cannot correctly return references but should always return identifier. Node should then apply the context and return the real Node objects.
             $dimensions = $context !== NULL ? $context->getDimensions() : array();
             $workspace = $context !== NULL ? $context->getWorkspace() : $this->getWorkspace();
             switch ($this->getNodeType()->getPropertyType($propertyName)) {
                 case 'references':
                     $nodeDatas = array();
                     if (!is_array($value)) {
                         $value = array();
                     }
                     $valueNeedsToBeFixed = FALSE;
                     foreach ($value as $nodeIdentifier) {
                         // in cases where a reference is a NodeData instance, fix this
                         if ($nodeIdentifier instanceof NodeData) {
                             $nodeIdentifier = $nodeIdentifier->getIdentifier();
                             $valueNeedsToBeFixed = TRUE;
                         }
                         if ($returnNodesAsIdentifiers === FALSE) {
                             $nodeData = $this->nodeDataRepository->findOneByIdentifier($nodeIdentifier, $workspace, $dimensions);
                             if ($nodeData instanceof NodeData) {
                                 $nodeDatas[] = $nodeData;
                             }
                         } else {
                             $nodeDatas[] = $nodeIdentifier;
                         }
                     }
                     if ($valueNeedsToBeFixed === TRUE) {
                         $fixedValue = array();
                         foreach ($value as $nodeIdentifier) {
                             if ($nodeIdentifier instanceof NodeData) {
                                 $fixedValue[] = $nodeIdentifier->getIdentifier();
                             } else {
                                 $fixedValue[] = $nodeIdentifier;
                             }
                         }
                         $this->properties[$propertyName] = $fixedValue;
                         $this->update();
                     }
                     $value = $nodeDatas;
                     break;
                 case 'reference':
                     // in cases where a reference is a NodeData instance, fix this
                     if ($value instanceof NodeData) {
                         $value = $value->getIdentifier();
                         $this->properties[$propertyName] = $value;
                         $this->update();
                     }
                     if ($returnNodesAsIdentifiers === FALSE) {
                         $nodeData = $this->nodeDataRepository->findOneByIdentifier($value, $workspace, $dimensions);
                         if ($nodeData instanceof NodeData) {
                             $value = $nodeData;
                         } else {
                             $value = NULL;
                         }
                     }
                     break;
             }
         }
         return $value;
     } elseif (ObjectAccess::isPropertyGettable($this->contentObjectProxy->getObject(), $propertyName)) {
         return ObjectAccess::getProperty($this->contentObjectProxy->getObject(), $propertyName);
     }
     throw new \TYPO3\TYPO3CR\Exception\NodeException(sprintf('Property "%s" does not exist in content object of type %s.', $propertyName, get_class($this->contentObjectProxy->getObject())), 1291286995);
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:80,代码来源:AbstractNodeData.php

示例6: findFirstByParentAndNodeTypeInContext

 /**
  * Finds a single node by its parent and (optionally) by its node type
  *
  * @param string $parentPath Absolute path of the parent node
  * @param string $nodeTypeFilter Filter the node type of the nodes, allows complex expressions (e.g. "TYPO3.Neos:Page", "!TYPO3.Neos:Page,TYPO3.Neos:Text" or NULL)
  * @param Context $context The containing context
  * @return NodeData The node found or NULL
  */
 public function findFirstByParentAndNodeTypeInContext($parentPath, $nodeTypeFilter, Context $context)
 {
     $firstNode = $this->findFirstByParentAndNodeType($parentPath, $nodeTypeFilter, $context->getWorkspace(), $context->getDimensions(), $context->isRemovedContentShown() ? null : false);
     if ($firstNode !== null) {
         $firstNode = $this->nodeFactory->createFromNodeData($firstNode, $context);
     }
     return $firstNode;
 }
开发者ID:testbird,项目名称:neos-development-collection,代码行数:16,代码来源:NodeDataRepository.php

示例7: adjustToContext

 /**
  * Adjust this instance to the given context.
  *
  * Internal use only!
  *
  * @param Context $context
  * @throws \TYPO3\TYPO3CR\Exception\InvalidNodeContextException
  */
 public function adjustToContext(Context $context)
 {
     $this->setWorkspace($context->getWorkspace());
     $nodeDimensions = new \Doctrine\Common\Collections\ArrayCollection();
     $targetDimensionValues = $context->getTargetDimensions();
     foreach ($context->getDimensions() as $dimensionName => $dimensionValues) {
         if (!isset($targetDimensionValues[$dimensionName])) {
             throw new \TYPO3\TYPO3CR\Exception\InvalidNodeContextException(sprintf('Missing target value for dimension "%"', $dimensionName), 1391686089);
         }
         $dimensionValueToSet = $targetDimensionValues[$dimensionName];
         $nodeDimensions->add(new NodeDimension($this, $dimensionName, $dimensionValueToSet));
     }
     $this->setDimensions($nodeDimensions);
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:22,代码来源:NodeData.php


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