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

Add public alias for offering dependency injection #30

Open
beephotography opened this issue Apr 8, 2020 · 1 comment
Open

Add public alias for offering dependency injection #30

beephotography opened this issue Apr 8, 2020 · 1 comment

Comments

@beephotography
Copy link

beephotography commented Apr 8, 2020

This is more like a question to you, @lennerd:
We're currently upgrading from a Symfony 3 application to Symfony 4 and we're using this bundle (is this still under development, because most recent commits are 2 years ago?)

So as we're upgrading, we want to use this bundle via correct dependency injection (not via the container ->get()), but that is not possible without a workaround, as there is no alias to the vipx_bot_detect.detector service ID.

We want to use it via constructor injection (with autowire: true in our service definition):

<?php
use Symfony\Component\HttpFoundation\RequestStack;
use Vipx\BotDetectBundle\BotDetector;

class BotManager
{
    public function __construct(RequestStack $requestStack, BotDetector $botDetector)
    {
        $this->meta = $botDetector->detectFromRequest($requestStack->getCurrentRequest());
    }
}

My workaround to this issue would be to add some

    Vipx\BotDetectBundle\BotDetector:
        alias: vipx_bot_detect.detector
        public: true

to our services.yml but I don't think that this is a good idea.

I'm relatively new to Symfony and I don't know if this is really an issue with your bundle, but I just wanted to go the "quick way" via Github, I hope that's OK for you.

@lennerd
Copy link
Owner

lennerd commented Apr 11, 2020

Hey @beephotography,

thanks for using this bundle! TBH I haven't used Symfony for a very long time and I do not plane to use it in the near feature. Also the list of bots (especially the less popular ones) in this repository might be outdated, so be careful when using it.

But: if you like to improve this bundle for example to be compatible with Symfony 4 feel free to create a PR. Same is true for updating the bot configurations. Would love to see this bundle beeing improved and updated.

Does this answer your questions?

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

2 participants