本文整理汇总了PHP中TYPO3\Flow\Reflection\ObjectAccess::buildSetterMethodName方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess::buildSetterMethodName方法的具体用法?PHP ObjectAccess::buildSetterMethodName怎么用?PHP ObjectAccess::buildSetterMethodName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Reflection\ObjectAccess
的用法示例。
在下文中一共展示了ObjectAccess::buildSetterMethodName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addOptions
/**
* @param array $options
* @return void
*/
public function addOptions(array $options)
{
foreach ($options as $key => $value) {
$setterName = $setterName = ObjectAccess::buildSetterMethodName($key);
if (method_exists($this, $setterName)) {
$this->{$setterName}($value);
} else {
$this->setOption($key, $value);
}
}
}
示例2: mapOneToObject
/**
* @param array $objectData
* @param string $objectClass
* @param array $settings
* @param string $key
* @return object
* @throws Exception
*/
protected function mapOneToObject($objectData, $objectClass, $settings, $key = '')
{
if (!is_array($objectData)) {
throw new Exception('Object mapping is not possible with given unexpected data for ObjectClass ' . $objectClass . ': ' . json_encode($objectData), 1408468371);
}
$object = $this->getNewInstanceOfObject($objectClass);
$properties = ObjectAccess::getSettablePropertyNames($object);
foreach ($properties as $property) {
$value = $this->getPropertyValue($object, $property, $objectData, $settings, $key);
if (isset($value)) {
$setterName = ObjectAccess::buildSetterMethodName($property);
$object->{$setterName}($value);
}
}
return $object;
}
示例3: getTypeOfChildProperty
/**
* The type of a property is determined by the reflection service.
*
* @param string $targetType
* @param string $propertyName
* @param PropertyMappingConfigurationInterface $configuration
* @return string
* @throws InvalidTargetException
*/
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
{
$configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue('TYPO3\\Flow\\Property\\TypeConverter\\PersistentObjectConverter', self::CONFIGURATION_TARGET_TYPE);
if ($configuredTargetType !== NULL) {
return $configuredTargetType;
}
$schema = $this->reflectionService->getClassSchema($targetType);
$setterMethodName = ObjectAccess::buildSetterMethodName($propertyName);
if ($schema->hasProperty($propertyName)) {
$propertyInformation = $schema->getProperty($propertyName);
return $propertyInformation['type'] . ($propertyInformation['elementType'] !== NULL ? '<' . $propertyInformation['elementType'] . '>' : '');
} elseif ($this->reflectionService->hasMethod($targetType, $setterMethodName)) {
$methodParameters = $this->reflectionService->getMethodParameters($targetType, $setterMethodName);
$methodParameter = current($methodParameters);
if (!isset($methodParameter['type'])) {
throw new InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158);
} else {
return $methodParameter['type'];
}
} else {
throw new InvalidTargetException('Property "' . $propertyName . '" was not found in target object of type "' . $targetType . '".', 1297978366);
}
}
示例4: getTypeOfChildProperty
/**
* The type of a property is determined by the reflection service.
*
* @param string $targetType
* @param string $propertyName
* @param PropertyMappingConfigurationInterface $configuration
* @return string
* @throws InvalidTargetException
*/
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
{
$configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(\TYPO3\Flow\Property\TypeConverter\ObjectConverter::class, self::CONFIGURATION_TARGET_TYPE);
if ($configuredTargetType !== NULL) {
return $configuredTargetType;
}
$methodParameters = $this->reflectionService->getMethodParameters($targetType, '__construct');
if (isset($methodParameters[$propertyName]) && isset($methodParameters[$propertyName]['type'])) {
return $methodParameters[$propertyName]['type'];
} elseif ($this->reflectionService->hasMethod($targetType, ObjectAccess::buildSetterMethodName($propertyName))) {
$methodParameters = $this->reflectionService->getMethodParameters($targetType, ObjectAccess::buildSetterMethodName($propertyName));
$methodParameter = current($methodParameters);
if (!isset($methodParameter['type'])) {
throw new InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158);
} else {
return $methodParameter['type'];
}
} else {
$targetPropertyNames = $this->reflectionService->getClassPropertyNames($targetType);
if (in_array($propertyName, $targetPropertyNames)) {
$values = $this->reflectionService->getPropertyTagValues($targetType, $propertyName, 'var');
if (count($values) > 0) {
return current($values);
} else {
throw new InvalidTargetException(sprintf('Public property "%s" had no proper type annotation (i.e. "@var") in target object of type "%s".', $propertyName, $targetType), 1406821818);
}
}
}
throw new InvalidTargetException(sprintf('Property "%s" has neither a setter or constructor argument, nor is public, in target object of type "%s".', $propertyName, $targetType), 1303379126);
}
示例5: getTypeOfChildProperty
/**
* The type of a property is determined by the reflection service.
*
* @param string $targetType
* @param string $propertyName
* @param PropertyMappingConfigurationInterface $configuration
* @return string
* @throws InvalidTargetException
*/
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
{
$configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(ObjectConverter::class, self::CONFIGURATION_TARGET_TYPE);
if ($configuredTargetType !== null) {
return $configuredTargetType;
}
$methodParameters = $this->reflectionService->getMethodParameters($targetType, '__construct');
if (isset($methodParameters[$propertyName]) && isset($methodParameters[$propertyName]['type'])) {
return $methodParameters[$propertyName]['type'];
} elseif ($this->reflectionService->hasMethod($targetType, ObjectAccess::buildSetterMethodName($propertyName))) {
$methodParameters = $this->reflectionService->getMethodParameters($targetType, ObjectAccess::buildSetterMethodName($propertyName));
$methodParameter = current($methodParameters);
if (!isset($methodParameter['type'])) {
throw new InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158);
} else {
return $methodParameter['type'];
}
} else {
$targetPropertyNames = $this->reflectionService->getClassPropertyNames($targetType);
if (in_array($propertyName, $targetPropertyNames)) {
$varTagValues = $this->reflectionService->getPropertyTagValues($targetType, $propertyName, 'var');
if (count($varTagValues) > 0) {
// This ensures that FQCNs are returned without leading backslashes. Otherwise, something like @var \DateTime
// would not find a property mapper. It is needed because the ObjectConverter doesn't use class schemata,
// but reads the annotations directly.
$declaredType = strtok(trim(current($varTagValues), " \n\t"), " \n\t");
try {
$parsedType = TypeHandling::parseType($declaredType);
} catch (InvalidTypeException $exception) {
throw new \InvalidArgumentException(sprintf($exception->getMessage(), 'class "' . $targetType . '" for property "' . $propertyName . '"'), 1467699674);
}
return $parsedType['type'] . ($parsedType['elementType'] !== null ? '<' . $parsedType['elementType'] . '>' : '');
} else {
throw new InvalidTargetException(sprintf('Public property "%s" had no proper type annotation (i.e. "@var") in target object of type "%s".', $propertyName, $targetType), 1406821818);
}
}
}
throw new InvalidTargetException(sprintf('Property "%s" has neither a setter or constructor argument, nor is public, in target object of type "%s".', $propertyName, $targetType), 1303379126);
}
示例6: getTypeOfChildProperty
/**
* The type of a property is determined by the reflection service.
*
* @param string $targetType
* @param string $propertyName
* @param \TYPO3\Flow\Property\PropertyMappingConfigurationInterface $configuration
* @return string
* @throws \TYPO3\Flow\Property\Exception\InvalidTargetException
*/
public function getTypeOfChildProperty($targetType, $propertyName, \TYPO3\Flow\Property\PropertyMappingConfigurationInterface $configuration)
{
$configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue('TYPO3\\Flow\\Property\\TypeConverter\\ObjectConverter', self::CONFIGURATION_TARGET_TYPE);
if ($configuredTargetType !== NULL) {
return $configuredTargetType;
}
if ($this->reflectionService->hasMethod($targetType, \TYPO3\Flow\Reflection\ObjectAccess::buildSetterMethodName($propertyName))) {
$methodParameters = $this->reflectionService->getMethodParameters($targetType, \TYPO3\Flow\Reflection\ObjectAccess::buildSetterMethodName($propertyName));
$methodParameter = current($methodParameters);
if (!isset($methodParameter['type'])) {
throw new \TYPO3\Flow\Property\Exception\InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158);
} else {
return $methodParameter['type'];
}
} else {
$methodParameters = $this->reflectionService->getMethodParameters($targetType, '__construct');
if (isset($methodParameters[$propertyName]) && isset($methodParameters[$propertyName]['type'])) {
return $methodParameters[$propertyName]['type'];
} else {
throw new \TYPO3\Flow\Property\Exception\InvalidTargetException('Property "' . $propertyName . '" had no setter or constructor argument in target object of type "' . $targetType . '".', 1303379126);
}
}
}
示例7: convertChangeData
/**
* Convert array to change interface
*
* @param array $changeData
* @return ChangeInterface
*/
protected function convertChangeData($changeData)
{
$type = $changeData['type'];
if (!isset($this->typeMap[$type])) {
return new \TYPO3\Flow\Error\Error(sprintf('Could not convert change type %s, it is unknown to the system', $type));
}
$changeClass = $this->typeMap[$type];
$changeClassInstance = $this->objectManager->get($changeClass);
$changeClassInstance->injectPersistenceManager($this->persistenceManager);
$subjectContextPath = $changeData['subject'];
$subject = $this->nodeService->getNodeFromContextPath($subjectContextPath);
if ($subject instanceof \TYPO3\Flow\Error\Error) {
return $subject;
}
$changeClassInstance->setSubject($subject);
if (isset($changeData['reference']) && method_exists($changeClassInstance, 'setReference')) {
$referenceContextPath = $changeData['reference'];
$reference = $this->nodeService->getNodeFromContextPath($referenceContextPath);
if ($reference instanceof \TYPO3\Flow\Error\Error) {
return $reference;
}
$changeClassInstance->setReference($reference);
}
if (isset($changeData['payload'])) {
foreach ($changeData['payload'] as $propertyName => $value) {
if (!in_array($propertyName, $this->disallowedPayloadProperties)) {
$methodParameters = $this->reflectionService->getMethodParameters($changeClass, ObjectAccess::buildSetterMethodName($propertyName));
$methodParameter = current($methodParameters);
$targetType = $methodParameter['type'];
$value = $this->propertyMapper->convert($value, $targetType);
ObjectAccess::setProperty($changeClassInstance, $propertyName, $value);
}
}
}
return $changeClassInstance;
}