nowiko
nowiko

Reputation: 2567

Difference between DependencyInjection and import in config file

I cant understand what difference between imoprt services in config file, or create DependencyInjection directory:

config.yml:

imports:    
- { resource: @VputiUserBundle/Resources/config/services.xml }

DependencyInjection:

public function load(array $configs, ContainerBuilder $container)
{
    $configuration = new Configuration();
    $config = $this->processConfiguration($configuration, $configs);

    $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
    $loader->load('services.xml');
}

Upvotes: 1

Views: 124

Answers (1)

ghostika
ghostika

Reputation: 1503

If you use the full stack symfony2 framework, then there the config for every bundle is loaded by the default behaviour of sf, so you don't have to import it on your config.yml , nevertheless you can't import an xml file in a yml file. The config.yml contain your main configuration for the app, the service configs in the bundle container the services for the bundle. If you are publishing your bundle then there you can share also the services , what resides in your bundle. Also, in the load function, after loading in the services from file, you can manipulate them, if needed.

Upvotes: 1

Related Questions