Skip to content
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

Provide autowiring for Exporter class #244

Closed
Jerome1337 opened this issue Oct 22, 2018 · 5 comments
Closed

Provide autowiring for Exporter class #244

Jerome1337 opened this issue Oct 22, 2018 · 5 comments

Comments

@Jerome1337
Copy link

Feature Request

Provide autowiring for sonata.exporter.exporter class

Cannot autowire argument $exporter of "AppBundle\Controller\LogController::exportAction()": it references class "Exporter\Exporter" but no such service exists. You should maybe alias this class to the existing "sonata.exporter.exporter" service.

I actually need to use this workaround inside Kernel.php

$aliases = ([
    \Exporter\Exporter::class => 'sonata.exporter.exporter',
]);
@OskarStark
Copy link
Member

IMO its not a best practice to do that for a third party bundle, but I can be wrong

No need to do it in PHP, you can define an alias in your services.yaml file

@greg0ire
Copy link
Contributor

See symfony/symfony-docs#9886 not sure if we should do that for no services at all, or allow doing it for services relevant to the end user

@soullivaneuh
Copy link
Member

IMO its not a best practice

Where did you see that? It's done on many bundles. And how will you provide auto-wiring without this method?

The only better thing to do here is to provide an interface.

@greg0ire
Copy link
Contributor

greg0ire commented Nov 6, 2018

@OskarStark please see https://github.com/symfony/symfony-docs/blob/master/bundles/best_practices.rst#services, apparently the best practice is exactly what is proposed here.

@greg0ire
Copy link
Contributor

greg0ire commented Nov 6, 2018

@Jerome1337 would you please make a pull request for this?

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