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


PHP ObjectAccess::isPropertySettable方法代码示例

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


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

示例1: hydrate

 /**
  * @param array $row
  * @return object
  */
 public function hydrate(array $row)
 {
     $dto = $this->getNewDtoInstance();
     foreach ($row as $column => $value) {
         if (ObjectAccess::isPropertySettable($dto, $column)) {
             ObjectAccess::setProperty($dto, $column, $value);
         }
     }
     return $dto;
 }
开发者ID:flow2lab,项目名称:eventsourcing,代码行数:14,代码来源:DtoHydrator.php

示例2: indexAction

 /**
  * @param string $dataSourceIdentifier
  * @param NodeInterface $node
  * @return string
  * @throws NeosException
  */
 public function indexAction($dataSourceIdentifier, NodeInterface $node = null)
 {
     $dataSources = static::getDataSources($this->objectManager);
     if (!isset($dataSources[$dataSourceIdentifier])) {
         throw new NeosException(sprintf('Data source with identifier "%s" does not exist.', $dataSourceIdentifier), 1414088186);
     }
     /** @var $dataSource DataSourceInterface */
     $dataSource = new $dataSources[$dataSourceIdentifier]();
     if (ObjectAccess::isPropertySettable($dataSource, 'controllerContext')) {
         ObjectAccess::setProperty($dataSource, 'controllerContext', $this->controllerContext);
     }
     $arguments = $this->request->getArguments();
     unset($arguments['dataSourceIdentifier']);
     unset($arguments['node']);
     $values = $dataSource->getData($node, $arguments);
     $this->view->assign('value', $values);
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:23,代码来源:DataSourceController.php

示例3: create

 /**
  * Factory method which creates the specified transport with the given options.
  *
  * @param string $transportType Object name of the transport to create
  * @param array $transportOptions Options for the transport
  * @param array $transportArguments Constructor arguments for the transport
  * @return \TYPO3\SwiftMailer\TransportInterface The created transport instance
  * @throws Exception
  */
 public function create($transportType, array $transportOptions = array(), array $transportArguments = NULL)
 {
     if (!class_exists($transportType)) {
         throw new Exception('The specified transport backend "' . $transportType . '" does not exist.', 1269351207);
     }
     if (is_array($transportArguments)) {
         $class = new \ReflectionClass($transportType);
         $transport = $class->newInstanceArgs($transportArguments);
     } else {
         $transport = new $transportType();
     }
     foreach ($transportOptions as $optionName => $optionValue) {
         if (ObjectAccess::isPropertySettable($transport, $optionName)) {
             ObjectAccess::setProperty($transport, $optionName, $optionValue);
         }
     }
     return $transport;
 }
开发者ID:simstern,项目名称:swiftmailer,代码行数:27,代码来源:TransportFactory.php

示例4: buildObject

 /**
  *
  * @param string $objectName
  * @param array $overrideProperties
  * @param boolean $addObjectToPersistence
  * @return object
  */
 public function buildObject($objectName, $overrideProperties = array(), $addObjectToPersistence = FALSE)
 {
     if (!isset($this->fixtureDefinitions[$objectName])) {
         throw new \Exception('Object name ' . $objectName . ' not configured in fixture definitions');
     }
     $properties = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($this->fixtureDefinitions[$objectName], $overrideProperties);
     $className = isset($properties['__type']) ? $properties['__type'] : $this->baseType;
     unset($properties['__type']);
     $object = new $className();
     foreach ($properties as $propertyName => $propertyValue) {
         if (\TYPO3\Flow\Reflection\ObjectAccess::isPropertySettable($object, $propertyName)) {
             \TYPO3\Flow\Reflection\ObjectAccess::setProperty($object, $propertyName, $propertyValue);
         }
     }
     $this->setCustomProperties($object, $properties, $addObjectToPersistence);
     if ($addObjectToPersistence) {
         $this->addObjectToPersistence($object);
     }
     return $object;
 }
开发者ID:HofUniversityIWS,项目名称:backend,代码行数:27,代码来源:FixtureFactory.php

示例5: unserialize

 /**
  * @param array $serializedMessage
  * @return Message
  */
 public function unserialize($serializedMessage)
 {
     if (is_array($serializedMessage) === FALSE) {
         throw new \InvalidArgumentException('The ArraySerializer can only unserialize arrays.', 1427369045);
     }
     if (array_key_exists('messageType', $serializedMessage) === FALSE || array_key_exists('payload', $serializedMessage) === FALSE || is_array($serializedMessage['payload']) === FALSE) {
         throw new \InvalidArgumentException('The serialized message is corrupted.', 1427369459);
     }
     $messageType = str_replace('.', '\\', $serializedMessage['messageType']);
     if (class_exists($messageType) === FALSE) {
         throw new \InvalidArgumentException('Unserialization for message of type "' . $messageType . '" failed. No such class.', 1427369534);
     }
     $message = new $messageType();
     foreach ($serializedMessage['payload'] as $propertyName => $propertyValue) {
         if (ObjectAccess::isPropertySettable($message, $propertyName)) {
             ObjectAccess::setProperty($message, $propertyName, $propertyValue);
         }
     }
     return $message;
 }
开发者ID:flow2lab,项目名称:eventsourcing,代码行数:24,代码来源:ArraySerializer.php

示例6: convertFrom

 /**
  * Convert an object from $source to an entity or a value object.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return object|TargetNotFoundError the converted entity/value object or an instance of TargetNotFoundError if the object could not be resolved
  * @throws \InvalidArgumentException|InvalidTargetException
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = NULL)
 {
     if (is_array($source)) {
         if ($this->reflectionService->isClassAnnotatedWith($targetType, 'TYPO3\\Flow\\Annotations\\ValueObject')) {
             // Unset identity for value objects to use constructor mapping, since the identity is determined from
             // property values after construction
             unset($source['__identity']);
         }
         $object = $this->handleArrayData($source, $targetType, $convertedChildProperties, $configuration);
         if ($object instanceof TargetNotFoundError) {
             return $object;
         }
     } elseif (is_string($source)) {
         if ($source === '') {
             return NULL;
         }
         $object = $this->fetchObjectFromPersistence($source, $targetType);
         if ($object === NULL) {
             return new TargetNotFoundError(sprintf('Object of type "%s" with identity "%s" not found.', $targetType, $source), 1412283033);
         }
     } else {
         throw new \InvalidArgumentException('Only strings and arrays are accepted.', 1305630314);
     }
     $objectConstructorArguments = $this->getConstructorArgumentsForClass(get_class($object));
     foreach ($convertedChildProperties as $propertyName => $propertyValue) {
         // We need to check for "immutable" constructor arguments that have no setter and remove them.
         if (isset($objectConstructorArguments[$propertyName]) && !ObjectAccess::isPropertySettable($object, $propertyName)) {
             $currentPropertyValue = ObjectAccess::getProperty($object, $propertyName);
             if ($currentPropertyValue === $propertyValue) {
                 continue;
             } else {
                 $exceptionMessage = sprintf('Property "%s" having a value of type "%s" could not be set in target object of type "%s". The property has no setter and is not equal to the value in the object, in that case it would have been skipped.', $propertyName, is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue), $targetType);
                 throw new InvalidTargetException($exceptionMessage, 1421498771);
             }
         }
         $result = ObjectAccess::setProperty($object, $propertyName, $propertyValue);
         if ($result === FALSE) {
             $exceptionMessage = sprintf('Property "%s" having a value of type "%s" could not be set in target object of type "%s". Make sure that the property is accessible properly, for example via an appropriate setter method.', $propertyName, is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue), $targetType);
             throw new InvalidTargetException($exceptionMessage, 1297935345);
         }
     }
     return $object;
 }
开发者ID:sakona999,项目名称:flow-login,代码行数:53,代码来源:PersistentObjectConverter.php

示例7: setProperty

 /**
  * Sets the specified property.
  * If the node has a content object attached, the property will be set there
  * if it is settable.
  *
  * @param string $propertyName Name of the property
  * @param mixed $value Value of the property
  * @return void
  */
 public function setProperty($propertyName, $value)
 {
     if (!is_object($this->contentObjectProxy)) {
         switch ($this->getNodeType()->getPropertyType($propertyName)) {
             case 'references':
                 $nodeIdentifiers = array();
                 if (is_array($value)) {
                     foreach ($value as $nodeIdentifier) {
                         if ($nodeIdentifier instanceof NodeInterface || $nodeIdentifier instanceof AbstractNodeData) {
                             $nodeIdentifiers[] = $nodeIdentifier->getIdentifier();
                         } elseif (preg_match(UuidValidator::PATTERN_MATCH_UUID, $nodeIdentifier) !== 0) {
                             $nodeIdentifiers[] = $nodeIdentifier;
                         }
                     }
                 }
                 $value = $nodeIdentifiers;
                 break;
             case 'reference':
                 $nodeIdentifier = NULL;
                 if ($value instanceof NodeInterface || $value instanceof AbstractNodeData) {
                     $nodeIdentifier = $value->getIdentifier();
                 } elseif (preg_match(UuidValidator::PATTERN_MATCH_UUID, $value) !== 0) {
                     $nodeIdentifier = $value;
                 }
                 $value = $nodeIdentifier;
                 break;
         }
         if (isset($this->properties[$propertyName]) && $this->properties[$propertyName] === $value) {
             return;
         }
         $this->properties[$propertyName] = $value;
         $this->update();
     } elseif (ObjectAccess::isPropertySettable($this->contentObjectProxy->getObject(), $propertyName)) {
         $contentObject = $this->contentObjectProxy->getObject();
         ObjectAccess::setProperty($contentObject, $propertyName, $value);
         $this->updateContentObject($contentObject);
     }
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:47,代码来源:AbstractNodeData.php

示例8: isPropertySettableWorksOnStdClass

 /**
  * @test
  */
 public function isPropertySettableWorksOnStdClass()
 {
     $stdClassObject = new \stdClass();
     $stdClassObject->property = 'foo';
     $this->assertTrue(ObjectAccess::isPropertySettable($stdClassObject, 'property'));
     $this->assertFalse(ObjectAccess::isPropertySettable($stdClassObject, 'undefinedProperty'));
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:10,代码来源:ObjectAccessTest.php


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