本文整理汇总了PHP中TYPO3\Flow\Reflection\ObjectAccess::getGettableProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess::getGettableProperties方法的具体用法?PHP ObjectAccess::getGettableProperties怎么用?PHP ObjectAccess::getGettableProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Reflection\ObjectAccess
的用法示例。
在下文中一共展示了ObjectAccess::getGettableProperties方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertFrom
/**
* Actually convert from $source to $targetType, taking into account the fully
* built $convertedChildProperties and $configuration.
*
* The return value can be one of three types:
* - an arbitrary object, or a simple type (which has been created while mapping).
* This is the normal case.
* - NULL, indicating that this object should *not* be mapped (i.e. a "File Upload" Converter could return NULL if no file has been uploaded, and a silent failure should occur.
* - An instance of \TYPO3\Flow\Error\Error -- This will be a user-visible error message later on.
* Furthermore, it should throw an Exception if an unexpected failure (like a security error) occurred or a configuration issue happened.
*
* @param mixed $source
* @param string $targetType
* @param array $convertedChildProperties
* @param PropertyMappingConfigurationInterface $configuration
* @return mixed|\TYPO3\Flow\Error\Error the target type, or an error object if a user-error occurred
* @throws \TYPO3\Flow\Property\Exception\TypeConverterException thrown in case a developer error occurred
* @api
*/
public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = null)
{
$properties = ObjectAccess::getGettableProperties($source);
if ($source instanceof \Doctrine\ORM\Proxy\Proxy) {
$className = get_parent_class($source);
} else {
$className = get_class($source);
}
$properties = array_merge($properties, $convertedChildProperties);
if ($source instanceof \TYPO3\Flow\Persistence\Aspect\PersistenceMagicInterface) {
$properties['__identity'] = $this->persistenceManager->getIdentifierByObject($source);
}
$properties['__type'] = $className;
return $properties;
}
示例2: convertFrom
/**
* Convert an object from \TYPO3\Media\Domain\Model\ImageInterface to a json representation
*
* @param ImageInterface $source
* @param string $targetType must be 'string'
* @param array $convertedChildProperties
* @param \TYPO3\Flow\Property\PropertyMappingConfigurationInterface $configuration
* @return string|\TYPO3\Flow\Validation\Error The converted Image, a Validation Error or NULL
*/
public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\Flow\Property\PropertyMappingConfigurationInterface $configuration = NULL)
{
$data = array('__identity' => $this->persistenceManager->getIdentifierByObject($source), '__type' => TypeHandling::getTypeForValue($source));
if ($source instanceof \TYPO3\Media\Domain\Model\ImageVariant) {
$data['originalAsset'] = ['__identity' => $this->persistenceManager->getIdentifierByObject($source->getOriginalAsset())];
$adjustments = array();
foreach ($source->getAdjustments() as $adjustment) {
$index = TypeHandling::getTypeForValue($adjustment);
$adjustments[$index] = array();
foreach (\TYPO3\Flow\Reflection\ObjectAccess::getGettableProperties($adjustment) as $propertyName => $propertyValue) {
$adjustments[$index][$propertyName] = $propertyValue;
}
}
$data['adjustments'] = $adjustments;
}
return $data;
}
示例3: getProperties
/**
* Returns all properties of this node.
*
* If the node has a content object attached, the properties will be fetched
* there.
*
* @param boolean $returnNodesAsIdentifiers If enabled, references to nodes are returned as node identifiers instead of NodeData objects
* @param \TYPO3\TYPO3CR\Domain\Service\Context $context An optional Context if $returnNodesAsIdentifiers === TRUE
* @return array Property values, indexed by their name
*/
public function getProperties($returnNodesAsIdentifiers = FALSE, \TYPO3\TYPO3CR\Domain\Service\Context $context = NULL)
{
if (is_object($this->contentObjectProxy)) {
return ObjectAccess::getGettableProperties($this->contentObjectProxy->getObject());
}
$properties = array();
foreach (array_keys($this->properties) as $propertyName) {
$properties[$propertyName] = $this->getProperty($propertyName, $returnNodesAsIdentifiers, $context);
}
return $properties;
}
示例4: getProperties
/**
* Returns all properties of this node.
*
* If the node has a content object attached, the properties will be fetched
* there.
*
* @return array Property values, indexed by their name
*/
public function getProperties()
{
if (is_object($this->contentObjectProxy)) {
return ObjectAccess::getGettableProperties($this->contentObjectProxy->getObject());
}
$properties = array();
foreach (array_keys($this->properties) as $propertyName) {
$properties[$propertyName] = $this->getProperty($propertyName);
}
return $properties;
}
示例5: getGettablePropertiesReturnsPropertiesOfStdClass
/**
* @test
*/
public function getGettablePropertiesReturnsPropertiesOfStdClass()
{
$stdClassObject = new \stdClass();
$stdClassObject->property = 'string1';
$stdClassObject->property2 = NULL;
$stdClassObject->publicProperty2 = 42;
$expectedProperties = array('property' => 'string1', 'property2' => NULL, 'publicProperty2' => 42);
$actualProperties = ObjectAccess::getGettableProperties($stdClassObject);
$this->assertEquals($expectedProperties, $actualProperties, 'expectedProperties did not return the right values for the properties.');
}
示例6: getGettablePropertiesHandlesDoctrineProxy
/**
* @test
*/
public function getGettablePropertiesHandlesDoctrineProxy()
{
$proxyObject = new \TYPO3\Flow\Tests\Reflection\Fixture\Model\EntityWithDoctrineProxy();
$expectedProperties = array();
$actualProperties = ObjectAccess::getGettableProperties($proxyObject);
$this->assertEquals($expectedProperties, $actualProperties, 'expectedProperties did not return the right values for the properties.');
}
示例7: serialize
/**
* @param Message $message
* @return array
*/
public function serialize(Message $message)
{
$messageType = new ObjectName($message);
$data = ObjectAccess::getGettableProperties($message);
return ['messageType' => $messageType->getName(), 'payload' => $data];
}
示例8: applyAdjustment
/**
* Apply the given adjustment to the image variant.
* If an adjustment of the given type already exists, the existing one will be overridden by the new one.
*
* @param ImageAdjustmentInterface $adjustment
* @return void
*/
protected function applyAdjustment(ImageAdjustmentInterface $adjustment)
{
$existingAdjustmentFound = false;
$newAdjustmentClassName = TypeHandling::getTypeForValue($adjustment);
foreach ($this->adjustments as $existingAdjustment) {
if (TypeHandling::getTypeForValue($existingAdjustment) === $newAdjustmentClassName) {
foreach (ObjectAccess::getGettableProperties($adjustment) as $propertyName => $propertyValue) {
ObjectAccess::setProperty($existingAdjustment, $propertyName, $propertyValue);
}
$existingAdjustmentFound = true;
}
}
if (!$existingAdjustmentFound) {
$this->adjustments->add($adjustment);
$adjustment->setImageVariant($this);
$this->adjustments = $this->adjustments->matching(new \Doctrine\Common\Collections\Criteria(null, array('position' => 'ASC')));
}
$this->lastModified = new \DateTime();
}
示例9: serialize
/**
* @param Message $message
* @return array
*/
public function serialize(Message $message)
{
$type = str_replace('\\', '.', get_class($message));
$data = ObjectAccess::getGettableProperties($message);
return ['messageType' => $type, 'payload' => $data];
}