Skip to content

Commit 8d93d4b

Browse files
dunglasfabpot
authored andcommitted
[Serializer] ObjectNormalizer: throw if PropertyAccess isn't installed
1 parent 5be1795 commit 8d93d4b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Normalizer/ObjectNormalizer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
1717
use Symfony\Component\Serializer\Exception\CircularReferenceException;
1818
use Symfony\Component\Serializer\Exception\LogicException;
19+
use Symfony\Component\Serializer\Exception\RuntimeException;
1920
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
2021
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
2122

@@ -33,6 +34,10 @@ class ObjectNormalizer extends AbstractNormalizer
3334

3435
public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null)
3536
{
37+
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccess')) {
38+
throw new RuntimeException('The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it.');
39+
}
40+
3641
parent::__construct($classMetadataFactory, $nameConverter);
3742

3843
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();

0 commit comments

Comments
 (0)