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


PHP NodeData::getNodeType方法代码示例

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


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

示例1: execute

 /**
  * Change the property on the given node.
  *
  * @param NodeData $node
  * @return void
  */
 public function execute(NodeData $node)
 {
     foreach ($node->getNodeType()->getProperties() as $propertyName => $propertyConfiguration) {
         if (isset($propertyConfiguration['type']) && in_array(trim($propertyConfiguration['type']), $this->getHandledObjectTypes())) {
             if (!isset($nodeProperties)) {
                 $nodeRecordQuery = $this->entityManager->getConnection()->prepare('SELECT properties FROM typo3_typo3cr_domain_model_nodedata WHERE persistence_object_identifier=?');
                 $nodeRecordQuery->execute([$this->persistenceManager->getIdentifierByObject($node)]);
                 $nodeRecord = $nodeRecordQuery->fetch(\PDO::FETCH_ASSOC);
                 $nodeProperties = unserialize($nodeRecord['properties']);
             }
             if (!isset($nodeProperties[$propertyName]) || !is_object($nodeProperties[$propertyName])) {
                 continue;
             }
             /** @var Asset $assetObject */
             $assetObject = $nodeProperties[$propertyName];
             $nodeProperties[$propertyName] = null;
             $stream = $assetObject->getResource()->getStream();
             if ($stream === false) {
                 continue;
             }
             fclose($stream);
             $objectType = TypeHandling::getTypeForValue($assetObject);
             $objectIdentifier = ObjectAccess::getProperty($assetObject, 'Persistence_Object_Identifier', true);
             $nodeProperties[$propertyName] = array('__flow_object_type' => $objectType, '__identifier' => $objectIdentifier);
         }
     }
     if (isset($nodeProperties)) {
         $nodeUpdateQuery = $this->entityManager->getConnection()->prepare('UPDATE typo3_typo3cr_domain_model_nodedata SET properties=? WHERE persistence_object_identifier=?');
         $nodeUpdateQuery->execute([serialize($nodeProperties), $this->persistenceManager->getIdentifierByObject($node)]);
     }
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:37,代码来源:AssetTransformation.php

示例2: getNodeTypeReturnsFallbackNodeTypeForUnknownNodeType

 /**
  * @test
  */
 public function getNodeTypeReturnsFallbackNodeTypeForUnknownNodeType()
 {
     $mockFallbackNodeType = $this->getMockBuilder(NodeType::class)->disableOriginalConstructor()->getMock();
     $mockNonExistingNodeType = $this->getMockBuilder(NodeType::class)->disableOriginalConstructor()->getMock();
     $mockNonExistingNodeType->expects($this->atLeastOnce())->method('getName')->willReturn('definitelyNotAvailableNodeType');
     /** @var NodeTypeManager|\PHPUnit_Framework_MockObject_MockObject $mockNodeTypeManager */
     $mockNodeTypeManager = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager')->disableOriginalConstructor()->getMock();
     $mockNodeTypeManager->expects($this->atLeastOnce())->method('getNodeType')->with('definitelyNotAvailableNodeType')->will($this->returnValue($mockFallbackNodeType));
     $this->inject($this->nodeData, 'nodeTypeManager', $mockNodeTypeManager);
     $this->inject($this->nodeData, 'nodeType', $mockNonExistingNodeType);
     $this->assertSame($mockFallbackNodeType, $this->nodeData->getNodeType());
 }
开发者ID:hhoechtl,项目名称:neos-development-collection,代码行数:15,代码来源:NodeDataTest.php

示例3: createFromNodeData

 /**
  * Creates a node from the given NodeData container.
  *
  * If this factory has previously created a Node for the given $node and it's dimensions,
  * it will return the same node again.
  *
  * @param NodeData $nodeData
  * @param Context $context
  * @return \TYPO3\TYPO3CR\Domain\Model\NodeInterface
  * @throws \TYPO3\TYPO3CR\Exception\NodeConfigurationException if a configured 'class' for a Node does not exist or does not inherit NodeInterface
  */
 public function createFromNodeData(NodeData $nodeData, Context $context)
 {
     if ($nodeData->isInternal()) {
         return null;
     }
     $internalNodeIdentifier = $nodeData->getIdentifier() . spl_object_hash($context);
     // In case there is a Node with an internal NodeData (because the NodeData was changed in the meantime) we need to flush it.
     if (isset($this->nodes[$internalNodeIdentifier]) && $this->nodes[$internalNodeIdentifier]->getNodeData()->isInternal()) {
         unset($this->nodes[$internalNodeIdentifier]);
     }
     if (!isset($this->nodes[$internalNodeIdentifier])) {
         // Warning: Alternative node implementations are considered internal for now, feature can change or be removed anytime. We want to be sure it works well and makes sense before declaring it public.
         $class = $nodeData->getNodeType()->getConfiguration('class') ?: $this->objectManager->getClassNameByObjectName('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface');
         if (!in_array($class, static::getNodeInterfaceImplementations($this->objectManager))) {
             throw new NodeConfigurationException('The configured implementation class name "' . $class . '" for NodeType "' . $nodeData->getNodeType() . '" does not inherit from TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface.', 1406884014);
         }
         $this->nodes[$internalNodeIdentifier] = new $class($nodeData, $context);
     }
     $node = $this->nodes[$internalNodeIdentifier];
     return $this->filterNodeByContext($node, $context);
 }
开发者ID:hlubek,项目名称:neos-development-collection,代码行数:32,代码来源:NodeFactory.php

示例4: theNodeTypeCanBeSetAndRetrieved

 /**
  * @test
  */
 public function theNodeTypeCanBeSetAndRetrieved()
 {
     $nodeTypeManager = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $nodeTypeManager->expects($this->any())->method('getNodeType')->will($this->returnCallback(function ($name) {
         return new NodeType($name, array(), array());
     }));
     $this->nodeData->_set('nodeTypeManager', $nodeTypeManager);
     $this->assertEquals('unstructured', $this->nodeData->getNodeType()->getName());
     $myNodeType = $nodeTypeManager->getNodeType('typo3:mycontent');
     $this->nodeData->setNodeType($myNodeType);
     $this->assertEquals($myNodeType, $this->nodeData->getNodeType());
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:15,代码来源:NodeDataTest.php

示例5: matches

 /**
  * Returns TRUE if the given node is of the node type this filter expects.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
  * @return boolean
  */
 public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
 {
     if ($this->withSubTypes === true) {
         $nodeIsMatchingNodeType = $node->getNodeType()->isOfType($this->nodeTypeName);
     } else {
         // This is needed to get the raw string NodeType to prevent errors for NodeTypes that no longer exist.
         $nodeType = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($node, 'nodeType', true);
         $nodeIsMatchingNodeType = $nodeType === $this->nodeTypeName;
     }
     if ($this->exclude === true) {
         return !$nodeIsMatchingNodeType;
     }
     return $nodeIsMatchingNodeType;
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:20,代码来源:NodeType.php

示例6: generateCacheTags

 /**
  * Generates cache tags to be flushed for a node which is flushed on shutdown.
  *
  * Code duplicated from Neos' ContentCacheFlusher class
  *
  * @param NodeInterface|NodeData $node The node which has changed in some way
  * @return void
  */
 protected function generateCacheTags($node)
 {
     $this->tagsToFlush[ContentCache::TAG_EVERYTHING] = 'which were tagged with "Everything".';
     $nodeTypesToFlush = $this->getAllImplementedNodeTypes($node->getNodeType());
     foreach ($nodeTypesToFlush as $nodeType) {
         /** @var NodeType $nodeType */
         $nodeTypeName = $nodeType->getName();
         $this->tagsToFlush['NodeType_' . $nodeTypeName] = sprintf('which were tagged with "NodeType_%s" because node "%s" has changed and was of type "%s".', $nodeTypeName, $node->getPath(), $node->getNodeType()->getName());
     }
     $this->tagsToFlush['Node_' . $node->getIdentifier()] = sprintf('which were tagged with "Node_%s" because node "%s" has changed.', $node->getIdentifier(), $node->getPath());
     while ($node->getDepth() > 1) {
         $node = $node->getParent();
         if ($node === NULL) {
             break;
         }
         $this->tagsToFlush['DescendantOf_' . $node->getIdentifier()] = sprintf('which were tagged with "DescendantOf_%s" because node "%s" has changed.', $node->getIdentifier(), $node->getPath());
     }
     if ($node instanceof NodeInterface && $node->getContext() instanceof ContentContext) {
         $firstActiveDomain = $node->getContext()->getCurrentSite()->getFirstActiveDomain();
         if ($firstActiveDomain) {
             $this->domainsToFlush[] = $firstActiveDomain->getHostPattern();
         }
     }
 }
开发者ID:christophlehmann,项目名称:MOC.Varnish,代码行数:32,代码来源:ContentCacheFlusherService.php

示例7: getNodeType

 /**
  * Returns the node type of this node.
  *
  * @return \TYPO3\TYPO3CR\Domain\Model\NodeType
  * @api
  */
 public function getNodeType()
 {
     return $this->nodeData->getNodeType();
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:10,代码来源:Node.php

示例8: execute

 /**
  * Change the property on the given node.
  *
  * @param NodeData $node
  * @return void
  */
 public function execute(NodeData $node)
 {
     foreach ($node->getNodeType()->getProperties() as $propertyName => $propertyConfiguration) {
         if (isset($propertyConfiguration['type']) && ($propertyConfiguration['type'] === 'TYPO3\\Media\\Domain\\Model\\ImageInterface' || preg_match('/array\\<.*\\>/', $propertyConfiguration['type']))) {
             if (!isset($nodeProperties)) {
                 $nodeRecordQuery = $this->entityManager->getConnection()->prepare('SELECT properties FROM typo3_typo3cr_domain_model_nodedata WHERE persistence_object_identifier=?');
                 $nodeRecordQuery->execute([$this->persistenceManager->getIdentifierByObject($node)]);
                 $nodeRecord = $nodeRecordQuery->fetch(\PDO::FETCH_ASSOC);
                 $nodeProperties = unserialize($nodeRecord['properties']);
             }
             if (!isset($nodeProperties[$propertyName]) || empty($nodeProperties[$propertyName])) {
                 continue;
             }
             if ($propertyConfiguration['type'] === 'TYPO3\\Media\\Domain\\Model\\ImageInterface') {
                 $adjustments = array();
                 $oldVariantConfiguration = $nodeProperties[$propertyName];
                 if (is_array($oldVariantConfiguration)) {
                     foreach ($oldVariantConfiguration as $variantPropertyName => $property) {
                         switch (substr($variantPropertyName, 3)) {
                             case 'originalImage':
                                 /**
                                  * @var $originalAsset \TYPO3\Media\Domain\Model\Image
                                  */
                                 $originalAsset = $this->assetRepository->findByIdentifier($this->persistenceManager->getIdentifierByObject($property));
                                 break;
                             case 'processingInstructions':
                                 $adjustments = $this->processingInstructionsConverter->convertFrom($property, 'array');
                                 break;
                         }
                     }
                     $nodeProperties[$propertyName] = NULL;
                     if (isset($originalAsset)) {
                         $stream = $originalAsset->getResource()->getStream();
                         if ($stream === FALSE) {
                             continue;
                         }
                         fclose($stream);
                         $newImageVariant = new \TYPO3\Media\Domain\Model\ImageVariant($originalAsset);
                         foreach ($adjustments as $adjustment) {
                             $newImageVariant->addAdjustment($adjustment);
                         }
                         $originalAsset->addVariant($newImageVariant);
                         $this->assetRepository->update($originalAsset);
                         $nodeProperties[$propertyName] = $this->persistenceManager->getIdentifierByObject($newImageVariant);
                     }
                 }
             } elseif (preg_match('/array\\<.*\\>/', $propertyConfiguration['type'])) {
                 if (is_array($nodeProperties[$propertyName])) {
                     $convertedValue = [];
                     foreach ($nodeProperties[$propertyName] as $entryValue) {
                         if (!is_object($entryValue)) {
                             continue;
                         }
                         $stream = $entryValue->getResource()->getStream();
                         if ($stream === FALSE) {
                             continue;
                         }
                         fclose($stream);
                         $existingObjectIdentifier = NULL;
                         try {
                             $existingObjectIdentifier = $this->persistenceManager->getIdentifierByObject($entryValue);
                             if ($existingObjectIdentifier !== NULL) {
                                 $convertedValue[] = $existingObjectIdentifier;
                             }
                         } catch (\Exception $exception) {
                         }
                     }
                     $nodeProperties[$propertyName] = $convertedValue;
                 }
             }
         }
     }
     if (isset($nodeProperties)) {
         $nodeUpdateQuery = $this->entityManager->getConnection()->prepare('UPDATE typo3_typo3cr_domain_model_nodedata SET properties=? WHERE persistence_object_identifier=?');
         $nodeUpdateQuery->execute([serialize($nodeProperties), $this->persistenceManager->getIdentifierByObject($node)]);
     }
 }
开发者ID:radmiraal,项目名称:neos-development-collection,代码行数:83,代码来源:ImageVariantTransformation.php

示例9: getOrderingHash

 /**
  * Get properties ordering hash
  *
  * @param NodeData $nodeData
  * @return string
  */
 public function getOrderingHash(NodeData $nodeData)
 {
     $data = '';
     foreach ($nodeData->getNodeType()->getConfiguration('indexedNodes')['properties'] as $key => $val) {
         $data .= $key . ":";
     }
     return md5($data);
 }
开发者ID:miegli,项目名称:NEOSLIVE.IndexedNodes,代码行数:14,代码来源:IndexService.php


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