drupal/core/vendor/Symfony/Component/DependencyInjection
Dries 34ef955ae5 - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
..
Compiler - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
Dumper - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
Exception - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
Extension - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
Loader - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
ParameterBag - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
Tests - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
Alias.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
Container.php - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
ContainerAware.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
ContainerAwareInterface.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
ContainerBuilder.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
ContainerInterface.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
Definition.php - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
DefinitionDecorator.php - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
IntrospectableContainerInterface.php - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
LICENSE - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
Parameter.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
README.md - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
Reference.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
Scope.php - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
ScopeInterface.php - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
SimpleXMLElement.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
TaggedContainerInterface.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
Variable.php - Patch #1497230 by Rob Loach, pdrake, effulgentsia: Use Dependency Injection to handle object definitions. 2012-04-18 14:31:33 -04:00
composer.json - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00
phpunit.xml.dist - Patch #1542710 by BTMash, Crell: update to latest Symfony 2.1 code. 2012-04-28 18:07:40 -04:00

README.md

DependencyInjection Component

DependencyInjection manages your services via a robust and flexible Dependency Injection Container.

Here is a simple example that shows how to register services and parameters:

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

$sc = new ContainerBuilder();
$sc
    ->register('foo', '%foo.class%')
    ->addArgument(new Reference('bar'))
;
$sc->setParameter('foo.class', 'Foo');

$sc->get('foo');

Method Calls (Setter Injection):

$sc = new ContainerBuilder();

$sc
    ->register('bar', '%bar.class%')
    ->addMethodCall('setFoo', array(new Reference('foo')))
;
$sc->setParameter('bar.class', 'Bar');

$sc->get('bar');

Factory Class:

If your service is retrieved by calling a static method:

$sc = new ContainerBuilder();

$sc
    ->register('bar', '%bar.class%')
    ->setFactoryClass('%bar.class%')
    ->setFactoryMethod('getInstance')
    ->addArgument('Aarrg!!!')
;
$sc->setParameter('bar.class', 'Bar');

$sc->get('bar');

File Include:

For some services, especially those that are difficult or impossible to autoload, you may need the container to include a file before instantiating your class.

$sc = new ContainerBuilder();

$sc
    ->register('bar', '%bar.class%')
    ->setFile('/path/to/file')
    ->addArgument('Aarrg!!!')
;
$sc->setParameter('bar.class', 'Bar');

$sc->get('bar');

Resources

You can run the unit tests with the following command:

phpunit -c src/Symfony/Component/DependencyInjection/

If you also want to run the unit tests that depend on other Symfony Components, declare the following environment variables before running PHPUnit:

export SYMFONY_CONFIG=../path/to/Config
export SYMFONY_YAML=../path/to/Yaml