Skip to content

Empty class from the definition of the service #957

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
NicolasGuilloux opened this issue Oct 4, 2019 · 0 comments
Closed

Empty class from the definition of the service #957

NicolasGuilloux opened this issue Oct 4, 2019 · 0 comments

Comments

@NicolasGuilloux
Copy link

NicolasGuilloux commented Oct 4, 2019

Hello there !

I noticed a small bug about service definition in your bundle. If I declare an autowired service from Symfony 3.4, I must set the class parameter because of the BuildTopicSubscriberRoutesPass that needs it.

In fact, when autowiring/autoconfiguring services actually works, but the class value of the definition is set to null if not explicitly declared.

Here is a small example:

App\Bundle\RestBundle\Processor\GalaxyRecordProcessor:
    # class: App\Bundle\RestBundle\Processor\GalaxyRecordProcessor
    tags: { name: enqueue.topic_subscriber }

that produces the following error:

In BuildTopicSubscriberRoutesPass.php line 42:
                                              
  The processor class "" could not be found.

So the CompilerPass tries to get an empty class because it does not understand that the service name is actually the class. A small fix would be to replace this line:

$processorClass = $processorDefinition->getClass();

by this:

$processorClass = $processorDefinition->getClass() ?? $serviceId;

I'll make a PR as soon as possible (Oh my god ! That docker-compose up -d is killing me ! :p)

PS: Same thing for BuildCommandSubscriberRoutesPass by the way ;)

Cheers guys !

@makasim makasim closed this as completed in 684e83b Oct 4, 2019
makasim added a commit that referenced this issue Oct 4, 2019
Fix empty class for autowired services (Fix #957)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant