I have in config.yml:
parameters:
aaa:
bbb: 'Example'
If I pass this in service:
AppBundle\Service\Service:
arguments:
$bbb: '%aaa%'
Then this is working well and I have array, but if I pass:
AppBundle\Service\Service:
arguments:
$bbb: '%aaa.bbb%'
Then I have error:
The service "AppBundle\Service\Service" has a dependency on a non- existent parameter "aaa.bbb". You cannot access nested array items, do you want to inject "aaa" instead?
Is possible to pass only one value?
If individual elements are to be passed as arguments, then array elements along with their subscripts must be given in function call. To receive the elements, simple variables are used in function definition.
If you want to pass a single-dimension array as an argument in a function, you would have to declare a formal parameter in one of following three ways and all three declaration methods produce similar results because each tells the compiler that an integer pointer is going to be received.
Single array elements can also be passed as arguments. This can be done in exactly the same way as we pass variables to a function. This code appearing here is passing a single element of an array to a function: #include <stdio.
You have to have parameters like this:
parameters:
aaa.bbb: 'Example'
with purpose to re-use like:
AppBundle\Service\Service:
arguments:
$bbb: '%aaa.bbb%'
Otherwise, you have to pass whole array, you can't pass single element from array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With