$callbacks
$callbacks :
Provides recursive normalization and denormalization for AdWords objects for non-SOAP services like BatchJobService and reporting, using getters and setters in a similar manner to `GetSetMethodNormalizer`. Note that, however, this normalizer doesn't support attribute groups or specifying attributes to ignore and doesn't support handling of circular references because AdWords objects don't have any such references.
Normalization normalizes objects recursively and adds the xsi:type attribute for the objects whose class is a subclass of another.
Denormalization uses type hint from the xsi:type attribute and PHP DocBlock
@return
to instantiate objects recursively.
AdWordsNormalizer
can be used as an normalizer of Symfony's serializer:
$this->serializer = new Serializer(
[new AdWordsNormalizer(), new ArrayDenormalizer()]);
This normalizer accepts two named callbacks that can be used to help customize how objects are normalized and denormalized - one called "normalize" and one called "denormalize".
The callbacks can be set via setCallbacks
:
$adWordsNormalizer->setCallbacks([
'normalize' => $normalizeCallback,
'denormalize' => $denormalizeCallback
]);
The respective callback will be applied to each attribute during normalization and denormalization.
The expected callback signature is as follows:
// @param mixed $value the value to be normalized. For denormalized, the
// type of $value is string
// @param string $type the type of $value, which can be a PHPDoc recognized
// primitive (e.g., string, int, etc.) or the FQCN for objects
function transform($value, $type);
__construct(\Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface $classMetadataFactory = null,\Symfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverter = null)
\Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface | $classMetadataFactory | |
\Symfony\Component\Serializer\NameConverter\NameConverterInterface | $nameConverter |
isOneOrMany(array $array): boolean
Whether the specified array represents one object or contains a list of objects. This is used after deserialization as XML lists repeat elements so when there is only one element in a list, deserialization doesn't understand that it's a list of objects. If we know something is supposed to be a list this is used to tell us that a single object needs to be wrapped in an array.
We do this by checking to see whether the specified array has only sequential numeric keys. If not, then it's an object.
array | $array |
true if this array represents one object, false if it's a list of objects or empty
getReturnType(\phpDocumentor\Reflection\DocBlock $docBlock): string|null
Gets type from the PHP document block's `@return` tag.
\phpDocumentor\Reflection\DocBlock | $docBlock | the document block to get its |
the class name of the attribute or null if there
exists no @return
tag in the document block