Пример #1
0
 /**
  * The type of a property is determined by the reflection service.
  *
  * @param string $targetType
  * @param string $propertyName
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException
  */
 public function getTypeOfChildProperty($targetType, $propertyName, \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration)
 {
     $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\ObjectConverter::class, self::CONFIGURATION_TARGET_TYPE);
     if ($configuredTargetType !== null) {
         return $configuredTargetType;
     }
     $specificTargetType = $this->objectContainer->getImplementationClassName($targetType);
     if ($this->reflectionService->hasMethod($specificTargetType, \TYPO3\CMS\Extbase\Reflection\ObjectAccess::buildSetterMethodName($propertyName))) {
         $methodParameters = $this->reflectionService->getMethodParameters($specificTargetType, \TYPO3\CMS\Extbase\Reflection\ObjectAccess::buildSetterMethodName($propertyName));
         $methodParameter = current($methodParameters);
         if (!isset($methodParameter['type'])) {
             throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $specificTargetType . '".', 1303379158);
         } else {
             return $methodParameter['type'];
         }
     } else {
         $methodParameters = $this->reflectionService->getMethodParameters($specificTargetType, '__construct');
         if (isset($methodParameters[$propertyName]) && isset($methodParameters[$propertyName]['type'])) {
             return $methodParameters[$propertyName]['type'];
         } else {
             throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException('Property "' . $propertyName . '" had no setter or constructor argument in target object of type "' . $specificTargetType . '".', 1303379126);
         }
     }
 }
Пример #2
0
 /**
  * The type of a property is determined by the reflection service.
  *
  * @param string $targetType
  * @param string $propertyName
  * @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
  * @return string
  * @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException
  */
 public function getTypeOfChildProperty($targetType, $propertyName, \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration)
 {
     $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, self::CONFIGURATION_TARGET_TYPE);
     if ($configuredTargetType !== null) {
         return $configuredTargetType;
     }
     $specificTargetType = $this->objectContainer->getImplementationClassName($targetType);
     $schema = $this->reflectionService->getClassSchema($specificTargetType);
     if (!$schema->hasProperty($propertyName)) {
         throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException('Property "' . $propertyName . '" was not found in target object of type "' . $specificTargetType . '".', 1297978366);
     }
     $propertyInformation = $schema->getProperty($propertyName);
     return $propertyInformation['type'] . ($propertyInformation['elementType'] !== null ? '<' . $propertyInformation['elementType'] . '>' : '');
 }