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


PHP ObjectAccess::buildSetterMethodName方法代码示例

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


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

示例1: create

 /**
  * @param array $settings
  * @return \FluidTYPO3\Flux\Form\Container\Section
  */
 public static function create(array $settings)
 {
     /** @var ObjectManagerInterface $objectManager */
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     /** @var Section */
     $section = $objectManager->get('FluidTYPO3\\Flux\\Form\\Container\\Section');
     foreach ($settings as $settingName => $settingValue) {
         $setterMethodName = ObjectAccess::buildSetterMethodName($settingName);
         if (TRUE === method_exists($section, $setterMethodName)) {
             ObjectAccess::setProperty($section, $settingName, $settingValue);
         }
     }
     if (TRUE === isset($settings['objects'])) {
         foreach ($settings['objects'] as $fieldName => $objectSettings) {
             if (FALSE === isset($objectSettings['name'])) {
                 $objectSettings['name'] = $fieldName;
             }
             $object = Object::create($objectSettings);
             $section->add($object);
         }
     }
     return $section;
 }
开发者ID:JostBaron,项目名称:flux,代码行数:27,代码来源:Section.php

示例2: modify

 /**
  * Modifies the current Form Component by changing any properties
  * that were passed in $structure. If a component supports special
  * indices in $structure (for example a "fields" property) then
  * that component may specify its own `modify()` method and manually
  * process each of the specially supported keywords.
  *
  * For example, the AbstractFormContainer supports passing "fields"
  * and each field is then attempted fetched from children. If not
  * found, it is created (and the structure passed to the `create()`
  * function which uses the same structure syntax). If it already
  * exists, the `modify()` method is called on that object to trigger
  * the recursive modification of all child components.
  *
  * @param array $structure
  * @return FormInterface
  */
 public function modify(array $structure)
 {
     if (TRUE === isset($structure['options']) && TRUE === is_array($structure['options'])) {
         foreach ($structure['options'] as $name => $value) {
             $this->setVariable($name, $value);
         }
         unset($structure['options']);
     }
     foreach ($structure as $propertyName => $propertyValue) {
         $setterMethodName = ObjectAccess::buildSetterMethodName($propertyName);
         if (TRUE === method_exists($this, $setterMethodName)) {
             ObjectAccess::setProperty($this, $propertyName, $propertyValue);
         }
     }
     return $this;
 }
开发者ID:fluidtypo3,项目名称:flux,代码行数:33,代码来源:AbstractFormComponent.php

示例3: canCallAllGetterCounterpartsForChainableSetters

 /**
  * @test
  */
 public function canCallAllGetterCounterpartsForChainableSetters()
 {
     $instance = $this->createInstance();
     foreach ($this->chainProperties as $propertyName => $propertValue) {
         $setterMethodName = ObjectAccess::buildSetterMethodName($propertyName);
         $instance->{$setterMethodName}($propertValue);
         $result = ObjectAccess::getProperty($instance, $propertyName);
         $this->assertEquals($propertValue, $result);
     }
 }
开发者ID:busynoggin,项目名称:flux,代码行数:13,代码来源:AbstractFormTest.php

示例4: getTypeOfChildProperty

 /**
  * 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);
         }
     }
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:33,代码来源:ObjectConverter.php

示例5: canChainAllChainableSetters

 /**
  * @test
  * @param array $chainPropertiesAndValues
  * @return FieldInterface
  */
 public function canChainAllChainableSetters($chainPropertiesAndValues = NULL)
 {
     if (NULL === $chainPropertiesAndValues) {
         $chainPropertiesAndValues = $this->chainProperties;
     }
     $instance = $this->createInstance();
     foreach ($chainPropertiesAndValues as $propertyName => $propertValue) {
         $setterMethodName = ObjectAccess::buildSetterMethodName($propertyName);
         $chained = call_user_func_array(array($instance, $setterMethodName), array($propertValue));
         $this->assertSame($instance, $chained, 'The setter ' . $setterMethodName . ' on ' . $this->getObjectClassName() . ' does not support chaining.');
         if ($chained === $instance) {
             $instance = $chained;
         }
     }
     $this->performTestBuild($instance);
     return $instance;
 }
开发者ID:samuweiss,项目名称:TYPO3-Site,代码行数:22,代码来源:AbstractFormTest.php

示例6: create

 /**
  * @param array $settings
  * @return FormInterface
  */
 public static function create(array $settings = array())
 {
     /** @var ObjectManagerInterface $objectManager */
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $className = get_called_class();
     /** @var FormInterface $object */
     $object = $objectManager->get($className);
     foreach ($settings as $settingName => $settingValue) {
         $setterMethodName = ObjectAccess::buildSetterMethodName($settingName);
         if (TRUE === method_exists($object, $setterMethodName)) {
             ObjectAccess::setProperty($object, $settingName, $settingValue);
         }
     }
     if (TRUE === $object instanceof FieldContainerInterface && TRUE === isset($settings['fields'])) {
         foreach ($settings['fields'] as $fieldName => $fieldSettings) {
             if (FALSE === isset($fieldSettings['name'])) {
                 $fieldSettings['name'] = $fieldName;
             }
             $field = AbstractFormField::create($fieldSettings);
             $object->add($field);
         }
     }
     return $object;
 }
开发者ID:chrmue01,项目名称:typo3-starter-kit,代码行数:28,代码来源:AbstractFormComponent.php


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