This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Tests
Fabien Potencier 22586ca996 feature #20648 [DependencyInjection] Added a shortcut method for autowired definitions (wouterj)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DependencyInjection] Added a shortcut method for autowired definitions

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | todo

This is a simple proposal to make adding autowired definitions to the `ContainerBuilder` a little easier. Registering autowired services in PHP code was quite verbose at the moment, while the whole point of autowiring is quick service registration.

**Before**
```php
$container->register('app.twig_extension', AppExtension::class)
    ->setAutowired(true)
    ->addTag('twig.extension')
;
```

**After**
```php
$container->autowire('app.twig_extension', AppExtension::class)
    ->addTag('twig.extension')
;
```

With https://github.com/symfony/symfony/pull/20264, this will be even nicer:
```php
$container->autowire(AppExtension::class)
    ->addTag('twig.extension')
;
```

Commits
-------

6ef4ce8 Added a shortcut method for autowired definitions
2016-12-13 10:00:08 +01:00
..
Compiler Revert "feature #17608 [DependencyInjection] Autowiring: add setter injection support (dunglas)" 2016-11-02 10:26:25 +01:00
Config [DI] Only rebuild autowiring cache when actually needed 2016-04-03 09:35:21 +02:00
Dumper Merge branch '3.1' into 3.2 2016-12-08 16:18:22 +01:00
Extension fixed CS 2014-09-22 10:32:35 +02:00
Fixtures Merge branch '3.1' into 3.2 2016-12-08 16:18:22 +01:00
LazyProxy removed all @covers annotations 2015-11-01 14:17:24 -08:00
Loader Merge branch '3.1' into 3.2 2016-12-08 16:18:22 +01:00
ParameterBag [DI] Allow null as default env value 2016-11-23 14:12:24 +01:00
ContainerBuilderTest.php feature #20648 [DependencyInjection] Added a shortcut method for autowired definitions (wouterj) 2016-12-13 10:00:08 +01:00
ContainerTest.php [PhpUnitBridge] Drop ErrorAssert in favor of @expectedDeprecation 2016-10-21 22:33:10 +02:00
CrossCheckTest.php Fix PHP 7.1 related failures 2016-07-19 10:44:18 +02:00
DefinitionDecoratorTest.php Merge branch '2.8' into 3.1 2016-08-22 14:11:19 +02:00
DefinitionTest.php Merge branch '2.8' into 3.1 2016-09-24 08:56:48 -07:00
ParameterTest.php removed all @covers annotations 2015-11-01 14:17:24 -08:00
ReferenceTest.php removed all @covers annotations 2015-11-01 14:17:24 -08:00