Reputation: 1023
What is the correct way in Symfony to override the parent service argument and also add to the children more arguments? According to the documentation, I need to use "index_N". But how to add more arguments to the child service? In example:
services: # ...
App\Repository\DoctrineUserRepository:
parent: App\Repository\BaseDoctrineRepository
# overrides the public setting of the parent service
public: false
# appends the '@app.username_checker' argument to the parent
# argument list
arguments: ['@app.username_checker']
App\Repository\DoctrinePostRepository:
parent: App\Repository\BaseDoctrineRepository
# overrides the first argument (using the special index_N key)
arguments:
index_0: '@doctrine.custom_entity_manager'
// put here more arguments for the child service
Upvotes: 1
Views: 492
Reputation: 2299
Untested, but did you try using "named arguments", like here:
# overrides the first argument (using the special index_N key)
# and set named argument $usernameChecker
arguments:
index_0: '@doctrine.custom_entity_manager'
$usernameChecker: '@app.username_checker'
Upvotes: 1