Skip to content

[FrameworkBundle] Serializer not work without PropertyAccess component #24553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BoShurik opened this issue Oct 13, 2017 · 3 comments
Closed

Comments

@BoShurik
Copy link
Contributor

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.10

FrameworkBundle assumes that PropertyAccess component is present
https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L139

We need to add it as a dependency or optionally register serializer.normalizer.object service

@weaverryan
Copy link
Member

Related to #20588, but slightly different

fabpot added a commit that referenced this issue Oct 16, 2017
…'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
-------

b5246a7 [Serializer] ObjectNormalizer: throw if PropertyAccess isn't installed
@fabpot fabpot closed this as completed Oct 16, 2017
@BoShurik
Copy link
Contributor Author

I still can't use it.

bin/console throws an exception

PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "PropertyAccessor" from namespace "Symfony\Component\PropertyAccess".
Did you forget a "use" statement for another namespace? in /Users/boshurik/Projects/symfony-property-access-issue/var/cache/dev/srcDevDebugProjectContainer.php:435

I tried to remove ObjectNormalizer from container. Add to Kernel CompilerPassInterface

/**
 * @inheritDoc
 */
public function process(ContainerBuilder $container)
{
    $container->removeDefinition('serializer.normalizer.object');
    $container->removeDefinition(ObjectNormalizer::class);
}

but no results

@BoShurik
Copy link
Contributor Author

Got it. I should move compiler pass from kernel to separate class and set priority to maximum (execute before object.normalizer tag pass)

/**
 * @inheritDoc
 */
protected function build(ContainerBuilder $container)
{
    $container->addCompilerPass(new CompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1000);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants