Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #27065 [DI][Routing] Allow invokable objects to be used as PH…
…P-DSL loaders (aurimasniekis) This PR was squashed before being merged into the 4.1-dev branch (closes #27065). Discussion ---------- [DI][Routing] Allow invokable objects to be used as PHP-DSL loaders | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26583, #25630 | License | MIT | Doc PR | none Changed DI/Router PHPFileLoader to check is_object && is_callable instead of instance of Closure Commits ------- 662ff7e [DI][Routing] Allow invokable objects to be used as PHP-DSL loaders
- Loading branch information
Showing
7 changed files
with
69 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
10 changes: 10 additions & 0 deletions
10
src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/object.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,10 @@ | ||
|
||
services: | ||
service_container: | ||
class: Symfony\Component\DependencyInjection\ContainerInterface | ||
public: true | ||
synthetic: true | ||
App\BarService: | ||
class: App\BarService | ||
public: true | ||
arguments: [!service { class: FooClass }] |
14 changes: 14 additions & 0 deletions
14
src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/object.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,14 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
use App\BarService; | ||
|
||
return new class() { | ||
public function __invoke(ContainerConfigurator $c) | ||
{ | ||
$s = $c->services(); | ||
$s->set(BarService::class) | ||
->args(array(inline('FooClass'))); | ||
} | ||
}; |
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
32 changes: 32 additions & 0 deletions
32
src/Symfony/Component/Routing/Tests/Fixtures/php_object_dsl.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,32 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Routing\Loader\Configurator; | ||
|
||
return new class() { | ||
public function __invoke(RoutingConfigurator $routes) | ||
{ | ||
$routes | ||
->collection() | ||
->add('foo', '/foo') | ||
->condition('abc') | ||
->options(array('utf8' => true)) | ||
->add('buz', 'zub') | ||
->controller('foo:act'); | ||
|
||
$routes->import('php_dsl_sub.php') | ||
->prefix('/sub') | ||
->requirements(array('id' => '\d+')); | ||
|
||
$routes->import('php_dsl_sub.php') | ||
->namePrefix('z_') | ||
->prefix('/zub'); | ||
|
||
$routes->import('php_dsl_sub_root.php') | ||
->prefix('/bus', false); | ||
|
||
$routes->add('ouf', '/ouf') | ||
->schemes(array('https')) | ||
->methods(array('GET')) | ||
->defaults(array('id' => 0)); | ||
} | ||
}; |
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