8000 minor #16458 [DependencyInjection] Fix YAML example in "Defining a Se… · symfony/symfony-docs@cc7a726 · GitHub
[go: up one dir, main page]

Skip to content
  • Commit cc7a726

    Browse files
    committed
    minor #16458 [DependencyInjection] Fix YAML example in "Defining a Service Locator" section (jbieliauskas)
    This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Fix YAML example in "Defining a Service Locator" section Using this example in `v5.3.13` gives this error: ``` Symfony\Component\DependencyInjection\Definition::setArguments(): Argument #1 ($arguments) must be of type array, Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument given, called in /project/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php on line 527 ``` I assume this is because `!service_locator` is the first constructor argument but it's passed as an array of constructor arguments, in which case the example is not right. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- bd8b262 Fix YAML example in "Defining a Service Locator" section
    2 parents 35580b9 + bd8b262 commit cc7a726

    File tree

    1 file changed

    +4
    -3
    lines changed

    1 file changed

    +4
    -3
    lines changed

    service_container/service_subscribers_locators.rst

    Lines changed: 4 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -256,9 +256,10 @@ argument of type ``service_locator``:
    256256
    # config/services.yaml
    257257
    services:
    258258
    App\CommandBus:
    259-
    arguments: !service_locator
    260-
    App\FooCommand: '@app.command_handler.foo'
    261-
    App\BarCommand: '@app.command_handler.bar'
    259+
    arguments:
    260+
    - !service_locator
    261+
    App\FooCommand: '@app.command_handler.foo'
    262+
    App\BarCommand: '@app.command_handler.bar'
    262263
    263264
    .. code-block:: xml
    264265

    0 commit comments

    Comments
     (0)
    0