Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #24632 [DependencyInjection] Anonymous services in PHP DSL (u…
…nkind) This PR was merged into the 4.1-dev branch. Discussion ---------- [DependencyInjection] Anonymous services in PHP DSL | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | no | New feature? | enhancement for fluent PHP configs | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24493 | License | MIT | Doc PR | not yet See #24493: ```php $s->anonymous(SendEmailForRegisteredUser::class)->tag('listener'); ``` Commits ------- ee42276 [DI] Add way to register service with implicit name using the PHP DSL
- Loading branch information
Showing
6 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/Symfony/Component/DependencyInjection/Tests/Fixtures/StdClassDecorator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Tests\Fixtures; | ||
|
||
final class StdClassDecorator | ||
{ | ||
public function __construct(\stdClass $foo) | ||
{ | ||
$this->foo = $foo; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/anonymous.expected.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
services: | ||
service_container: | ||
class: Symfony\Component\DependencyInjection\ContainerInterface | ||
public: true | ||
synthetic: true | ||
listener_aggregator: | ||
class: Bar\FooClass | ||
public: true | ||
arguments: [!tagged listener] | ||
2_stdClass~%s: | ||
class: stdClass | ||
public: false | ||
tags: | ||
- { name: listener } | ||
decorated: | ||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\StdClassDecorator | ||
public: true | ||
arguments: [!service { class: stdClass, public: false }] |
21 changes: 21 additions & 0 deletions
21
src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/anonymous.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
use Bar\FooClass; | ||
use stdClass; | ||
use Symfony\Component\DependencyInjection\Tests\Fixtures\StdClassDecorator; | ||
|
||
return function (ContainerConfigurator $c) { | ||
$s = $c->services(); | ||
|
||
$s->set('decorated', stdClass::class); | ||
|
||
$s->set(null, StdClassDecorator::class) | ||
->decorate('decorated', 'decorator42') | ||
->args(array(ref('decorator42'))); | ||
|
||
$s->set('listener_aggregator', FooClass::class)->public()->args(array(tagged('listener'))); | ||
|
||
$s->set(null, stdClass::class)->tag('listener'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters