/**
  * @test
  */
 public function getTargetPropertyNameShouldReturnTheUnmodifiedPropertyNameWithoutConfiguration()
 {
     $defaultConfiguration = $this->propertyMappingConfigurationBuilder->build();
     $this->assertTrue($defaultConfiguration->getConfigurationValue('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED));
     $this->assertTrue($defaultConfiguration->getConfigurationValue('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED));
     $this->assertNull($defaultConfiguration->getConfigurationFor('foo')->getConfigurationValue('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED));
     $this->assertNull($defaultConfiguration->getConfigurationFor('foo')->getConfigurationValue('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED));
 }
Exemplo n.º 2
0
 /**
  * Map $source to $targetType, and return the result
  *
  * @param mixed $source the source data to map. MUST be a simple type, NO object allowed!
  * @param string $targetType The type of the target; can be either a class name or a simple type.
  * @param PropertyMappingConfigurationInterface $configuration Configuration for the property mapping. If NULL, the PropertyMappingConfigurationBuilder will create a default configuration.
  * @throws Exception
  * @return mixed an instance of $targetType
  * @api
  */
 public function convert($source, $targetType, PropertyMappingConfigurationInterface $configuration = NULL)
 {
     if ($configuration === NULL) {
         $configuration = $this->configurationBuilder->build();
     }
     $currentPropertyPath = array();
     $this->messages = new \TYPO3\CMS\Extbase\Error\Result();
     try {
         $result = $this->doMapping($source, $targetType, $configuration, $currentPropertyPath);
         if ($result instanceof \TYPO3\CMS\Extbase\Error\Error) {
             return NULL;
         }
         return $result;
     } catch (\Exception $e) {
         throw new Exception('Exception while property mapping at property path "' . implode('.', $currentPropertyPath) . '":' . $e->getMessage(), 1297759968, $e);
     }
 }