PHP Class ApiPlatform\Core\Serializer\AbstractItemNormalizer

Author: Kévin Dunglas ([email protected])
Inheritance: extends Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer, use trait ContextTrait
Show file Open project: api-platform/core Class Usage Examples

Protected Properties

Property Type Description
$iriConverter
$propertyAccessor
$propertyMetadataFactory
$propertyNameCollectionFactory
$resourceClassResolver

Public Methods

Method Description
__construct ( ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface $propertyMetadataFactory, ApiPlatform\Core\Api\IriConverterInterface $iriConverter, ApiPlatform\Core\Api\ResourceClassResolverInterface $resourceClassResolver, Symfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessor = null, Symfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverter = null )
denormalize ( $data, $class, $format = null, array $context = [] )
normalize ( $object, $format = null, array $context = [] )
supportsDenormalization ( $data, $type, $format = null )
supportsNormalization ( $data, $format = null )

Protected Methods

Method Description
createRelationSerializationContext ( string $resourceClass, array $context ) : array Creates the context to use when serializing a relation.
extractAttributes ( $object, $format = null, array $context = [] )
getAllowedAttributes ( $classOrObject, array $context, $attributesAsString = false )
getAttributeValue ( $object, $attribute, $format = null, array $context = [] )
getFactoryOptions ( array $context ) : array Gets a valid context for property metadata factories.
setAttributeValue ( $object, $attribute, $value, $format = null, array $context = [] )
validateType ( string $attribute, Symfony\Component\PropertyInfo\Type $type, mixed $value, string $format = null ) Validates the type of the value. Allows using integers as floats for JSON formats.

Private Methods

Method Description
denormalizeCollection ( string $attribute, PropertyMetadata $propertyMetadata, Symfony\Component\PropertyInfo\Type $type, string $className, mixed $value, string $format = null, array $context ) : array Denormalizes a collection of objects.
denormalizeRelation ( string $attributeName, PropertyMetadata $propertyMetadata, string $className, mixed $value, string $format = null, array $context ) : object | null Denormalizes a relation.
normalizeRelation ( PropertyMetadata $propertyMetadata, mixed $relatedObject, string $resourceClass, string $format = null, array $context ) : string | array Normalizes a relation as an URI if is a Link or as a JSON-LD object.
setValue ( object $object, string $attributeName, mixed $value ) Sets a value of the object using the PropertyAccess component.

Method Details

__construct() public method

public __construct ( ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface $propertyMetadataFactory, ApiPlatform\Core\Api\IriConverterInterface $iriConverter, ApiPlatform\Core\Api\ResourceClassResolverInterface $resourceClassResolver, Symfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessor = null, Symfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverter = null )
$propertyNameCollectionFactory ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface
$propertyMetadataFactory ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface
$iriConverter ApiPlatform\Core\Api\IriConverterInterface
$resourceClassResolver ApiPlatform\Core\Api\ResourceClassResolverInterface
$propertyAccessor Symfony\Component\PropertyAccess\PropertyAccessorInterface
$nameConverter Symfony\Component\Serializer\NameConverter\NameConverterInterface

createRelationSerializationContext() protected method

Creates the context to use when serializing a relation.
protected createRelationSerializationContext ( string $resourceClass, array $context ) : array
$resourceClass string
$context array
return array

denormalize() public method

public denormalize ( $data, $class, $format = null, array $context = [] )
$context array

extractAttributes() protected method

Unused in this context.
protected extractAttributes ( $object, $format = null, array $context = [] )
$context array

getAllowedAttributes() protected method

protected getAllowedAttributes ( $classOrObject, array $context, $attributesAsString = false )
$context array

getAttributeValue() protected method

protected getAttributeValue ( $object, $attribute, $format = null, array $context = [] )
$context array

getFactoryOptions() protected method

Gets a valid context for property metadata factories.
See also: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php
protected getFactoryOptions ( array $context ) : array
$context array
return array

normalize() public method

public normalize ( $object, $format = null, array $context = [] )
$context array

setAttributeValue() protected method

protected setAttributeValue ( $object, $attribute, $value, $format = null, array $context = [] )
$context array

supportsDenormalization() public method

public supportsDenormalization ( $data, $type, $format = null )

supportsNormalization() public method

public supportsNormalization ( $data, $format = null )

validateType() protected method

Validates the type of the value. Allows using integers as floats for JSON formats.
protected validateType ( string $attribute, Symfony\Component\PropertyInfo\Type $type, mixed $value, string $format = null )
$attribute string
$type Symfony\Component\PropertyInfo\Type
$value mixed
$format string

Property Details

$iriConverter protected property

protected $iriConverter

$propertyAccessor protected property

protected $propertyAccessor

$propertyMetadataFactory protected property

protected $propertyMetadataFactory

$propertyNameCollectionFactory protected property

protected $propertyNameCollectionFactory

$resourceClassResolver protected property

protected $resourceClassResolver