Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move Symfony2 service config to bundle

Tags:

I have the following in my config.yml

services:     my.user_provider:         class: Acme\MySecurityBundle\Security\UserProvider 

but would like to move this to config.yml in my MySecurityBundle/Resources/config but Symfony2 tells me that the service doesn't exist when I move it.

How do I get it to pick up the config.yml file from there?

like image 941
josef.van.niekerk Avatar asked Nov 29 '11 21:11

josef.van.niekerk


1 Answers

src/Acme/MySecurityBundle/DependencyInjection/MySecurityExtension.php:

<?php namespace Acme\MySecurityBundle\DependencyInjection;  use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\Config\FileLocator;  class MySecurityExtension extends Extension {     public function load(array $configs, ContainerBuilder $container)     {         $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));         $loader->load('services.yml');     } } 

src/Acme/MySecurityBundle/Resources/config/services.yml:

services:     my_security.user_provider:         class: Acme\MySecurityBundle\Security\UserProvider 
like image 70
Elnur Abdurrakhimov Avatar answered Sep 22 '22 09:09

Elnur Abdurrakhimov