X
X
xjasmx2019-12-11 22:22:39
symfony
xjasmx, 2019-12-11 22:22:39

How to pass an object with a parameter to the Service Container?

Good day!
I ran into a situation where the service needs to send an object with a parameter in service.yaml. Specifically, to implement oauth 2 League, the AuthorizationServer object needs to pass the grant itself to the enableGrantType method, and the DateInterval object with the parameter itself.
For example
calls:
- method: enableGrantType
arguments:
- '@League\OAuth2\Server\Grant\PasswordGrant'
- ?
The question is - how can such an injection be implemented through the Service Container Symfony?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2019-12-11
@xjasmx

You can do this: https://symfony.com/doc/current/service_container/...
Or you can do this: https://symfony.com/doc/current/service_container/...
Or even this: https://symfony .com/doc/current/service_container/...
In the first case, register your DateInterval as a service, in the second, create it inside the configurator/factory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question