Struggling to configure bundle with Symfony 3.4
wisdom-17 opened this issue · comments
Hi all,
I have an application which is using Symfony 3.4. I'm struggling to configure the BazingaGeocoderBundle.
I added the following in app/config/config.yaml:
bazinga_geocoder:
providers:
acme:
factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory
I'm having difficulty in accessing the provider from a service class I created, I tried to inject it in the constructor using Symfony's type hinting/auto wiring feature but I still get the following error when trying to use the service class.
I added this to the top of my service class:
use Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory;
and the constructor like this:
private $url;
private $googleMapsProvider;
public $outlets;
public $abnormalFormatOutlets;
public function __construct($url = null, GoogleMapsFactory $googleMapsProvider)
{
$this->url = $url;
$this->outlets = [];
$this->abnormalFormatOutlets = [];
$this->googleMapsProvider = $googleMapsProvider;
}
When trying to use this class, this is the error I get:
Type error: Too few arguments to function AppBundle\Utils\OutletScraper::__construct(), 1 passed in /myproject/src/Ap
pBundle/Command/OutletRetrieveCommand.php on line 42 and exactly 2 expected
Appreciate if anyone could point me in the right direction.
See here: https://github.com/geocoder-php/BazingaGeocoderBundle/blob/master/Resources/doc/index.md#usage
With your config, you create a service named bazinga_geocoder.provider.acme
which is a GoogleMapsProvider
. You should not use GoogleMapsFactory
.
Reading your error is seams like you have not updated the service definition for OutletScraper
.
So the following should be in services.yml? And not in config.yml
bazinga_geocoder:
providers:
acme:
factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory
No no, Your config looks fine. But show me where you define OutletScraper
Ah, the config for my OutletScraper (app/config/services.yml) looks like this:
AppBundle\Utils\OutletScraper:
public: false
autowire: true