Is there a way to set a public variable by means of the service definition in services.yml
?
The reason is, that i am using the phpbrowscap library. To use a local file for resolving the browser i need use this line of code:
$this->browscap->localFile = "..."
unfortunately this poor property is public and does not have a setter. it's neither available in constructor.
so how would i set this property in services.yml
? is that even possible to achieve?
this is the part in my services.yml
:
browscap:
class: Browscap
arguments:
- %browscap_cache_dir%
if there was a setter i would add call
there... but well...
Have you tried using the property injection
method of the DI-Container?
https://symfony.com/doc/current/service_container/injection_types.html#property-injection
app.newsletter_manager:
class: AppBundle\Mail\NewsletterManager
properties:
mailer: '@mailer'