Skip to content

Commit 4984ce1

Browse files
committed
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 ------- 1fd4e8b [DependencyInjection] Add abstract_arg() and param()
2 parents bb70cc8 + 1fd4e8b commit 4984ce1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

14+
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
1415
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
1516
use Symfony\Component\DependencyInjection\Definition;
1617
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
@@ -85,6 +86,7 @@ public static function processValue($value, $allowServices = false)
8586
case $value instanceof Definition:
8687
case $value instanceof Expression:
8788
case $value instanceof Parameter:
89+
case $value instanceof AbstractArgument:
8890
case $value instanceof Reference:
8991
if ($allowServices) {
9092
return $value;

src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

14+
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
1415
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1516
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
1617
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
@@ -82,6 +83,14 @@ final public function withPath(string $path): self
8283
}
8384
}
8485

86+
/**
87+
* Creates a parameter.
88+
*/
89+
function param(string $name): string
90+
{
91+
return '%'.$name.'%';
92+
}
93+
8594
/**
8695
* Creates a service reference.
8796
*
@@ -165,3 +174,11 @@ function expr(string $expression): Expression
165174
{
166175
return new Expression($expression);
167176
}
177+
178+
/**
179+
* Creates an abstract argument.
180+
*/
181+
function abstract_arg(string $description): AbstractArgument
182+
{
183+
return new AbstractArgument($description);
184+
}

0 commit comments

Comments
 (0)