ApiPlatform\Core\Serializer\AbstractItemNormalizer::__construct PHP Method

__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
    public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, IriConverterInterface $iriConverter, ResourceClassResolverInterface $resourceClassResolver, PropertyAccessorInterface $propertyAccessor = null, NameConverterInterface $nameConverter = null)
    {
        parent::__construct(null, $nameConverter);
        $this->propertyNameCollectionFactory = $propertyNameCollectionFactory;
        $this->propertyMetadataFactory = $propertyMetadataFactory;
        $this->iriConverter = $iriConverter;
        $this->resourceClassResolver = $resourceClassResolver;
        $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
        $this->setCircularReferenceHandler(function ($object) {
            return $this->iriConverter->getIriFromItem($object);
        });
    }

Usage Example

Example #1
0
 public function __construct(ResourceMetadataFactoryInterface $resourceMetadataFactory, PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, IriConverterInterface $iriConverter, ResourceClassResolverInterface $resourceClassResolver, ContextBuilderInterface $contextBuilder, PropertyAccessorInterface $propertyAccessor = null, NameConverterInterface $nameConverter = null)
 {
     parent::__construct($propertyNameCollectionFactory, $propertyMetadataFactory, $iriConverter, $resourceClassResolver, $propertyAccessor, $nameConverter);
     $this->resourceMetadataFactory = $resourceMetadataFactory;
     $this->contextBuilder = $contextBuilder;
 }