function AbstractObjectNormalizer::getAttributes
Gets and caches attributes for the given object, format and context.
Return value
string[]
1 call to AbstractObjectNormalizer::getAttributes()
- AbstractObjectNormalizer::normalize in vendor/
symfony/ serializer/ Normalizer/ AbstractObjectNormalizer.php - Normalizes data into a set of arrays/scalars.
File
-
vendor/
symfony/ serializer/ Normalizer/ AbstractObjectNormalizer.php, line 251
Class
- AbstractObjectNormalizer
- Base class for a normalizer dealing with objects.
Namespace
Symfony\Component\Serializer\NormalizerCode
protected function getAttributes(object $object, ?string $format, array $context) : array {
$class = ($this->objectClassResolver)($object);
$key = $class . '-' . $context['cache_key'];
if (isset($this->attributesCache[$key])) {
return $this->attributesCache[$key];
}
$allowedAttributes = $this->getAllowedAttributes($object, $context, true);
if (false !== $allowedAttributes) {
if ($context['cache_key']) {
$this->attributesCache[$key] = $allowedAttributes;
}
return $allowedAttributes;
}
$attributes = $this->extractAttributes($object, $format, $context);
if ($mapping = $this->classDiscriminatorResolver?->getMappingForMappedObject($object)) {
array_unshift($attributes, $mapping->getTypeProperty());
}
if ($context['cache_key'] && \stdClass::class !== $class) {
$this->attributesCache[$key] = $attributes;
}
return $attributes;
}