Reputation: 17181
What is the correct way to define service definition arguments in a Symfony 3.4 application?
I have noticed all of the following are valid:
AppBundle\Services\RFC\Spackman:
arguments:
$watpSdk: '@watp.client'
calls:
- [setPlayerName, ['%p_name%']]
AppBundle\Services\RFC\Gordon:
$client: '@crmpicco.client'
zendesk.client:
class: Zendesk\API\HttpClient
arguments:
- '%zendesk_subdomain%'
The official docs say this, however i'm unsure what the correct standard is:
New in version 3.3: The ability to configure an argument by its name ($adminEmail) was added in Symfony 3.3. Previously, you could configure it only by its index (2 in this case) or by using empty quotes for the other arguments.
Upvotes: 0
Views: 355
Reputation: 392
Any of them are proper ways of doing it. I prefer to use hyphens since, if you refactor the parameter's name someday, you won't have to refactor it in your configuration too.
I also use "index_#" when I need to extend service definition and replace one of the arguments defined in the parent service.
It's a matter of taste, since service extension can be completely ignored.
Upvotes: 1