VipxBotDetectBundle
VipxBotDetectBundle copied to clipboard
Add public alias for offering dependency injection
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.