July 2017
Intermediate to advanced
456 pages
11h 32m
English
In addition to the arguments and calls, you can also set public fields on the service class directly. The properties metadata is a hash of attributes and references to other services. For instance, if you had a service class like:
class MyService { public $database;}
You could define the metadata like:
test.my_service: properties: value: '@database'
There are some fairly significant disadvantages to doing this, however. The first is that the Service Container will set the value on instantiation; there is no other control on when that value could be set. It could be changed at any point in the object's lifetime and there is no way to track this. The other is, there is no way to hint the class property. In other ways of injecting ...
Read now
Unlock full access