bug #24563 [Serializer] ObjectNormalizer: throw if PropertyAccess isn't installed (dunglas)
This PR was squashed before being merged into the 2.7 branch (closes #24563).
Discussion
----------
[Serializer] ObjectNormalizer: throw if PropertyAccess isn't installed
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass? | yes
| Fixed tickets | #24553
| License | MIT
| Doc PR | n/a
Commits
-------
b5246a72ca
[Serializer] ObjectNormalizer: throw if PropertyAccess isn't installed
This commit is contained in:
commit
7dac168800
|
@ -16,6 +16,7 @@ use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||||
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
||||||
use Symfony\Component\Serializer\Exception\CircularReferenceException;
|
use Symfony\Component\Serializer\Exception\CircularReferenceException;
|
||||||
use Symfony\Component\Serializer\Exception\LogicException;
|
use Symfony\Component\Serializer\Exception\LogicException;
|
||||||
|
use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||||
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
|
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
|
||||||
|
|
||||||
|
@ -33,6 +34,10 @@ class ObjectNormalizer extends AbstractNormalizer
|
||||||
|
|
||||||
public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null)
|
public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null)
|
||||||
{
|
{
|
||||||
|
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccess')) {
|
||||||
|
throw new RuntimeException('The ObjectNormalizer class requires the "PropertyAccess" component. Install "symfony/property-access" to use it.');
|
||||||
|
}
|
||||||
|
|
||||||
parent::__construct($classMetadataFactory, $nameConverter);
|
parent::__construct($classMetadataFactory, $nameConverter);
|
||||||
|
|
||||||
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
|
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
|
||||||
|
|
Reference in New Issue