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


PHP PropertyMapper::convert方法代码示例

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


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

示例1: rewriteSiteAssetCollection

 /**
  * @Flow\Before("method(TYPO3\Neos\Controller\Backend\ContentController->uploadAssetAction())")
  * @param JoinPointInterface $joinPoint The current join point
  * @return void
  */
 public function rewriteSiteAssetCollection(JoinPointInterface $joinPoint)
 {
     if ($this->lookupNodeFilter === NULL || $this->lookupPropertyName === NULL) {
         return;
     }
     /** @var ContentController $contentController */
     $contentController = $joinPoint->getProxy();
     /** @var ActionRequest $actionRequest */
     $actionRequest = ObjectAccess::getProperty($contentController, 'request', TRUE);
     $nodeContextPath = $actionRequest->getInternalArgument('__node');
     if ($nodeContextPath === NULL) {
         return;
     }
     $node = $this->propertyMapper->convert($nodeContextPath, NodeInterface::class);
     $flowQuery = new FlowQuery(array($node));
     /** @var NodeInterface $documentNode */
     $documentNode = $flowQuery->closest($this->lookupNodeFilter)->get(0);
     if (!$documentNode->hasProperty($this->lookupPropertyName)) {
         return;
     }
     /** @var AssetCollection $assetCollection */
     $assetCollection = $this->assetCollectionRepository->findByIdentifier($documentNode->getProperty($this->lookupPropertyName));
     if ($assetCollection === NULL) {
         return;
     }
     /** @var Asset $asset */
     $asset = $joinPoint->getMethodArgument('asset');
     $assetCollection->addAsset($asset);
     $this->assetCollectionRepository->update($assetCollection);
 }
开发者ID:bwaidelich,项目名称:Wwwision.AssetConstraints,代码行数:35,代码来源:ContentControllerAspect.php

示例2: getIssuerOrganizationFromConfiguration

 /**
  * @param string $identifier
  * @param array $issuerOrganizationConfiguration
  * @return IssuerOrganization
  */
 protected function getIssuerOrganizationFromConfiguration($identifier, $issuerOrganizationConfiguration)
 {
     /** @var IssuerOrganization $issuerOrganization */
     $issuerOrganization = $this->propertyMapper->convert($issuerOrganizationConfiguration, 'Networkteam\\OpenBadges\\Domain\\Model\\IssuerOrganization');
     $issuerOrganization->setIdentifier($identifier);
     return $issuerOrganization;
 }
开发者ID:christophlehmann,项目名称:Networkteam.OpenBadges,代码行数:12,代码来源:ConfigurableIssuerOrganizationsRepository.php

示例3: convertFrom

 /**
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface|null $configuration
  * @return mixed|\Netlogix\JsonApiOrg\Schema\ResourceInterface|\TYPO3\Flow\Error\Error
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = null)
 {
     if (is_string($source)) {
         $sourceArray = json_decode($source, true);
         $source = is_array($sourceArray) ? $sourceArray : ['id' => $source];
     }
     if (!array_key_exists('type', $source)) {
         $dummyPayload = $this->objectManager->get($targetType);
         $typeIdentifier = $dummyPayload->getType();
         $source['type'] = $this->exposableTypeMap->getType($typeIdentifier);
     }
     if (array_key_exists('id', $source)) {
         $arguments = $source['id'];
     } else {
         $arguments = [];
     }
     $payload = $this->propertyMapper->convert($arguments, $this->exposableTypeMap->getClassName($source['type']));
     $resourceInformation = $this->resourceMapper->findResourceInformation($payload);
     $resource = $resourceInformation->getResource($payload);
     if (isset($source['attributes'])) {
         $attributes = $resource->getAttributes();
         foreach ($source['attributes'] as $fieldName => $value) {
             $attributes[$fieldName] = $value;
         }
     }
     if (isset($source['relationships'])) {
         $relationships = $resource->getRelationships();
         foreach ($source['relationships'] as $fieldName => $value) {
             $relationships[$fieldName] = $value;
         }
     }
     return $resource;
 }
开发者ID:netlogix,项目名称:jsonapiorg,代码行数:40,代码来源:ResourceConverter.php

示例4: convert

 /**
  * Convert raw property values to the correct type according to a node type configuration
  *
  * @param NodeType $nodeType
  * @param string $propertyName
  * @param string $rawValue
  * @param Context $context
  * @return mixed
  */
 public function convert(NodeType $nodeType, $propertyName, $rawValue, Context $context)
 {
     $propertyType = $nodeType->getPropertyType($propertyName);
     switch ($propertyType) {
         case 'string':
             return $rawValue;
         case 'reference':
             return $this->convertReference($rawValue, $context);
         case 'references':
             return $this->convertReferences($rawValue, $context);
         case 'DateTime':
             return $this->convertDateTime($rawValue);
         case 'integer':
             return $this->convertInteger($rawValue);
         case 'boolean':
             return $this->convertBoolean($rawValue);
         case 'array':
             return $this->convertArray($rawValue);
         default:
             $innerType = $propertyType;
             if ($propertyType !== null) {
                 try {
                     $parsedType = \TYPO3\Flow\Utility\TypeHandling::parseType($propertyType);
                     $innerType = $parsedType['elementType'] ?: $parsedType['type'];
                 } catch (\TYPO3\Flow\Utility\Exception\InvalidTypeException $exception) {
                 }
             }
             if (is_string($rawValue) && $this->objectManager->isRegistered($innerType) && $rawValue !== '') {
                 return $this->propertyMapper->convert(json_decode($rawValue, true), $propertyType, $configuration);
             }
     }
 }
开发者ID:skurfuerst,项目名称:PackageFactory.Guevara,代码行数:41,代码来源:NodePropertyConversionService.php

示例5: resourceRequest

 /**
  * @param array $requestData
  * @return array
  * @throws \Exception
  * @throws \TYPO3\Flow\Property\Exception
  * @throws \TYPO3\Flow\Security\Exception
  */
 public function resourceRequest(array $requestData)
 {
     /** @var Resource $resource */
     $resource = $this->propertyMapper->convert($requestData[RequestStack::RESULT_DATA_IDENTIFIER], Resource::class);
     if (!$resource) {
         throw new \Exception('This request data can not be processed', 1452854971);
     }
     return json_decode(json_encode($resource), true);
 }
开发者ID:netlogix,项目名称:jsonapiorg,代码行数:16,代码来源:ResourceResolverByMapping.php

示例6: getUploadedResource

 /**
  * Returns a previously uploaded resource.
  * If errors occurred during property mapping for this property, NULL is returned
  *
  * @return \TYPO3\Flow\Resource\Resource
  */
 protected function getUploadedResource()
 {
     if ($this->getMappingResultsForProperty()->hasErrors()) {
         return NULL;
     }
     $resourceObject = $this->getValue(FALSE);
     if ($resourceObject instanceof \TYPO3\Flow\Resource\Resource) {
         return $resourceObject;
     }
     return $this->propertyMapper->convert($resourceObject, 'TYPO3\\Flow\\Resource\\Resource');
 }
开发者ID:sinso,项目名称:TYPO3.Flow,代码行数:17,代码来源:UploadedResourceViewHelper.php

示例7: getUploadedImage

 /**
  * Returns a previously uploaded image.
  * If errors occurred during property mapping for this property, NULL is returned
  *
  * @return \TYPO3\Media\Domain\Model\Image
  */
 protected function getUploadedImage()
 {
     if ($this->getMappingResultsForProperty()->hasErrors()) {
         return NULL;
     }
     $image = $this->getValue(FALSE);
     if ($image instanceof \TYPO3\Media\Domain\Model\Image) {
         return $image;
     }
     return $this->propertyMapper->convert($image, 'TYPO3\\Media\\Domain\\Model\\Image');
 }
开发者ID:sinso,项目名称:TYPO3.Flow,代码行数:17,代码来源:UploadedImageViewHelper.php

示例8: getUploadedResource

 /**
  * Returns a previously uploaded resource.
  * If errors occurred during property mapping for this property, NULL is returned
  *
  * @return Resource
  */
 protected function getUploadedResource()
 {
     if ($this->getMappingResultsForProperty()->hasErrors()) {
         return null;
     }
     $resourceObject = $this->getValue(false);
     if ($resourceObject instanceof PersistentResource) {
         return $resourceObject;
     }
     return $this->propertyMapper->convert($resourceObject, PersistentResource::class);
 }
开发者ID:kitsunet,项目名称:form,代码行数:17,代码来源:UploadedResourceViewHelper.php

示例9: getUploadedImage

 /**
  * Returns a previously uploaded image.
  * If errors occurred during property mapping for this property, NULL is returned
  *
  * @return Image
  */
 protected function getUploadedImage()
 {
     if ($this->getMappingResultsForProperty()->hasErrors()) {
         return null;
     }
     $image = $this->getValue(false);
     if ($image instanceof Image) {
         return $image;
     }
     return $this->propertyMapper->convert($image, Image::class);
 }
开发者ID:kitsunet,项目名称:form,代码行数:17,代码来源:UploadedImageViewHelper.php

示例10: convertFrom

 /**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  *
  * The return value can be one of three types:
  * - an arbitrary object, or a simple type (which has been created while mapping).
  *   This is the normal case.
  * - NULL, indicating that this object should *not* be mapped (i.e. a "File Upload" Converter could return NULL if no file has been uploaded, and a silent failure should occur.
  * - An instance of \TYPO3\Flow\Error\Error -- This will be a user-visible error message later on.
  * Furthermore, it should throw an Exception if an unexpected failure (like a security error) occurred or a configuration issue happened.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return mixed|\TYPO3\Flow\Error\Error the target type, or an error object if a user-error occurred
  * @throws \TYPO3\Flow\Property\Exception\TypeConverterException thrown in case a developer error occurred
  * @api
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = NULL)
 {
     $result = array();
     $convertElements = $configuration->getConfigurationValue(\TYPO3\Flow\Persistence\Doctrine\ArrayTypeConverter::class, self::CONFIGURATION_CONVERT_ELEMENTS);
     foreach ($source as $element) {
         if ($convertElements === TRUE) {
             $element = $this->propertyMapper->convert($element, 'array', $configuration);
         }
         $result[] = $element;
     }
     return $result;
 }
开发者ID:nlx-sascha,项目名称:flow-development-collection,代码行数:31,代码来源:ArrayTypeConverter.php

示例11: entityWithImmutablePropertyCanNotBeUpdatedWhenImmutablePropertyChanged

 /**
  * @test
  * @expectedException \TYPO3\Flow\Property\Exception
  */
 public function entityWithImmutablePropertyCanNotBeUpdatedWhenImmutablePropertyChanged()
 {
     $result = $this->propertyMapper->convert($this->sourceProperties, \TYPO3\Flow\Tests\Functional\Property\Fixtures\TestEntityWithImmutableProperty::class);
     $identifier = $this->persistenceManager->getIdentifierByObject($result);
     $this->persistenceManager->add($result);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $update = array('__identity' => $identifier, 'age' => '25', 'name' => 'Christian D');
     $result = $this->propertyMapper->convert($update, \TYPO3\Flow\Tests\Functional\Property\Fixtures\TestEntityWithImmutableProperty::class);
     $this->assertInstanceOf(\TYPO3\Flow\Tests\Functional\Property\Fixtures\TestEntityWithImmutableProperty::class, $result);
     $this->assertEquals('Christian M', $result->getName());
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:16,代码来源:PersistentObjectConverterTest.php

示例12: convertFrom

 /**
  * Actually convert from $source to $targetType, taking into account the fully
  * built $convertedChildProperties and $configuration.
  *
  * The return value can be one of three types:
  * - an arbitrary object, or a simple type (which has been created while mapping).
  *   This is the normal case.
  * - NULL, indicating that this object should *not* be mapped (i.e. a "File Upload" Converter could return NULL if no file has been uploaded, and a silent failure should occur.
  * - An instance of Error -- This will be a user-visible error message later on.
  * Furthermore, it should throw an Exception if an unexpected failure (like a security error) occurred or a configuration issue happened.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return mixed|Error the target type, or an error object if a user-error occurred
  * @throws TypeConverterException thrown in case a developer error occurred
  * @api
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
 {
     $result = [];
     $convertElements = $configuration->getConfigurationValue(ArrayTypeConverter::class, self::CONFIGURATION_CONVERT_ELEMENTS);
     foreach ($source as $element) {
         if ($convertElements === true) {
             $element = $this->propertyMapper->convert($element, 'array', $configuration);
         }
         $result[] = $element;
     }
     return $result;
 }
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:31,代码来源:ArrayTypeConverter.php

示例13: mapParty

 /**
  * Map the party from the given source data
  *
  * @param array $source
  * @return \TYPO3\Party\Domain\Model\AbstractParty
  */
 protected function mapParty(array $source)
 {
     if (!isset($source['__type'])) {
         throw new Exception('Cannot map party without explicit type (server should return "__type" in party account data):' . json_encode($source), 1354111717);
     }
     $partyType = $source['__type'];
     unset($source['__type']);
     if (isset($this->typeMapping[$partyType])) {
         $partyType = $this->typeMapping[$partyType];
     }
     $configuration = new TrustedPropertyMappingConfiguration();
     // TODO Deal with mapping errors from property mapper
     return $this->propertyMapper->convert($source, $partyType, $configuration);
 }
开发者ID:anihy,项目名称:Flowpack.SingleSignOn.Client,代码行数:20,代码来源:SimpleGlobalAccountMapper.php

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

示例15: applyTypeSpecificHandling

 /**
  * Converts and adds ImageAdjustments to the ImageVariant
  *
  * @param ImageInterface $asset
  * @param mixed $source
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return ImageInterface|NULL
  */
 protected function applyTypeSpecificHandling($asset, $source, array $convertedChildProperties, PropertyMappingConfigurationInterface $configuration)
 {
     if ($asset instanceof ImageVariant) {
         $adjustments = [];
         if (isset($source['adjustments'])) {
             foreach ($source['adjustments'] as $adjustmentType => $adjustmentOptions) {
                 if (isset($adjustmentOptions['__type'])) {
                     $adjustmentType = $adjustmentOptions['__type'];
                     unset($adjustmentOptions['__type']);
                 }
                 $identity = null;
                 if (isset($adjustmentOptions['__identity'])) {
                     $identity = $adjustmentOptions['__identity'];
                     unset($adjustmentOptions['__identity']);
                 }
                 $adjustment = $this->propertyMapper->convert($adjustmentOptions, $adjustmentType, $configuration);
                 if ($identity !== null) {
                     ObjectAccess::setProperty($adjustment, 'persistence_object_identifier', $identity, true);
                 }
                 $adjustments[] = $adjustment;
             }
         } elseif (isset($source['processingInstructions'])) {
             $adjustments = $this->processingInstructionsConverter->convertFrom($source['processingInstructions'], 'array');
         }
         if (count($adjustments) > 0) {
             $asset->addAdjustments($adjustments);
         }
     }
     return $asset;
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:39,代码来源:ImageInterfaceConverter.php


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