feature #36775 [DependencyInjection] Add abstract_arg() and param() (fabpot)

This PR was squashed before being merged into the 5.2-dev branch.

Discussion
----------

[DependencyInjection] Add abstract_arg() and param()

| Q             | A
| ------------- | ---
| Branch?       | maste
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | -

Added abstract_arg() and param() to configuration abstract arguments in PHP DSL.

Commits
-------

1fd4e8bb60 [DependencyInjection] Add abstract_arg() and param()
This commit is contained in:
Fabien Potencier 2020-06-10 04:11:49 +02:00
commit 4984ce1036
2 changed files with 19 additions and 0 deletions

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
@ -85,6 +86,7 @@ abstract class AbstractConfigurator
case $value instanceof Definition:
case $value instanceof Expression:
case $value instanceof Parameter:
case $value instanceof AbstractArgument:
case $value instanceof Reference:
if ($allowServices) {
return $value;

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
@ -82,6 +83,14 @@ class ContainerConfigurator extends AbstractConfigurator
}
}
/**
* Creates a parameter.
*/
function param(string $name): string
{
return '%'.$name.'%';
}
/**
* Creates a service reference.
*
@ -165,3 +174,11 @@ function expr(string $expression): Expression
{
return new Expression($expression);
}
/**
* Creates an abstract argument.
*/
function abstract_arg(string $description): AbstractArgument
{
return new AbstractArgument($description);
}