Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ObjectNormalizer.php

function ObjectNormalizer::__construct

Overrides AbstractObjectNormalizer::__construct

File

vendor/symfony/serializer/Normalizer/ObjectNormalizer.php, line 45

Class

ObjectNormalizer
Converts between objects and arrays using the PropertyAccess component.

Namespace

Symfony\Component\Serializer\Normalizer

Code

public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory = null, ?NameConverterInterface $nameConverter = null, ?PropertyAccessorInterface $propertyAccessor = null, ?PropertyTypeExtractorInterface $propertyTypeExtractor = null, ?ClassDiscriminatorResolverInterface $classDiscriminatorResolver = null, ?callable $objectClassResolver = null, array $defaultContext = [], ?PropertyInfoExtractorInterface $propertyInfoExtractor = null) {
    if (!class_exists(PropertyAccess::class)) {
        throw new LogicException('The ObjectNormalizer class requires the "PropertyAccess" component. Try running "composer require symfony/property-access".');
    }
    parent::__construct($classMetadataFactory, $nameConverter, $propertyTypeExtractor, $classDiscriminatorResolver, $objectClassResolver, $defaultContext);
    $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
    $this->objectClassResolver = ($objectClassResolver ?? static fn($class) => \is_object($class) ? $class::class : $class)(...);
    $this->propertyInfoExtractor = $propertyInfoExtractor ?: new ReflectionExtractor();
    $this->writeInfoExtractor = new ReflectionExtractor();
}
RSS feed
Powered by Drupal