Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #27075 [DI][DX] Allow exclude to be an array of patterns (mag…
…netik) This PR was merged into the 4.2-dev branch. Discussion ---------- [DI][DX] Allow exclude to be an array of patterns | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23956 | License | MIT This is basically continuing #24428. In YAML before: ```yaml AppBundle\: resource: '../../src/AppBundle/*' exclude: '../../src/AppBundle/{Entity,Payload,Repository}' ``` in YAML after: ```yaml AppBundle\: resource: '../../src/AppBundle/*' exclude: - '../../src/AppBundle/{Entity,Payload,Repository}' - '../../src/AppBundle/Event/*Event.php' ``` In XML before: ```xml <prototype namespace="App\" resource="../src/*" exclude="../src/{Entity,Migrations,Tests}" /> ``` in XML after: ```xml <prototype namespace="App\" resource="../src/*"> <exclude>../src/{Entity,Migrations,Tests}</exclude> <exclude>../src/Yolo</exclude> </prototype> ``` In PHP before: ```php $di->load(Prototype::class.'\\', '../Prototype') ->autoconfigure() ->exclude('../Prototype/{OtherDir,BadClasses}') ``` In PHP after: ```php $di->load(Prototype::class.'\\', '../Prototype') ->autoconfigure() ->exclude(['../Prototype/OtherDir', '../Prototype/BadClasses']) ``` Everything is backward compatible. Maybe a decision about handling both attribute exclude and element exclude in XML should be taken. Commits ------- 3ae3a03 [DI][DX] Allow exclude to be an array of patterns (taking #24428 over)
- Loading branch information
Showing
9 changed files
with
119 additions
and
14 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
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
25 changes: 25 additions & 0 deletions
25
src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/prototype_array.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,25 @@ | ||
|
||
services: | ||
service_container: | ||
class: Symfony\Component\DependencyInjection\ContainerInterface | ||
public: true | ||
synthetic: true | ||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo: | ||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo | ||
public: true | ||
tags: | ||
- { name: foo } | ||
- { name: baz } | ||
deprecated: "%service_id%" | ||
arguments: [1] | ||
factory: f | ||
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar: | ||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar | ||
public: true | ||
tags: | ||
- { name: foo } | ||
- { name: baz } | ||
deprecated: "%service_id%" | ||
lazy: true | ||
arguments: [1] | ||
factory: f |
22 changes: 22 additions & 0 deletions
22
src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/prototype_array.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,22 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
use Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype; | ||
|
||
return function (ContainerConfigurator $c) { | ||
$di = $c->services()->defaults() | ||
->tag('baz'); | ||
$di->load(Prototype::class.'\\', '../Prototype') | ||
->autoconfigure() | ||
->exclude(array('../Prototype/OtherDir', '../Prototype/BadClasses')) | ||
->factory('f') | ||
->deprecate('%service_id%') | ||
->args(array(0)) | ||
->args(array(1)) | ||
->autoconfigure(false) | ||
->tag('foo') | ||
->parent('foo'); | ||
$di->set('foo')->lazy()->abstract(); | ||
$di->get(Prototype\Foo::class)->lazy(false); | ||
}; |
9 changes: 9 additions & 0 deletions
9
src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_prototype_array.xml
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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<prototype namespace="Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\" resource="../Prototype/*"> | ||
<exclude>../Prototype/OtherDir</exclude> | ||
<exclude>../Prototype/BadClasses</exclude> | ||
</prototype> | ||
</services> | ||
</container> |
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