but if you do the above, you MUST instantiate all your classes with
otherwise you'll need to call
new YourClass($widthParameter) as with normal PHP.
You can read more about the power of injector here: https://docs.silverstripe.org/en/4/developer_guides/extending/injector/
Arguably the docs are actually better in the class itself 😂 :P https://github.com/silverstripe/silverstripe-framework/blob/4.4.4/src/Core/Injector/Injector.php#L18-L131
There are other ways to do this with injector, via property setters, or public properties.
- public $width
You can use injector to set this property after it has created the object. OR
- private $width;
- public function setWidth($width)
- $this->width = $width;
Both of these can be set via
- width: 80
(be aware I've stripped the namespaces for brevity)
you may need a capital W to match the setter function if you do that way.
I hope this has been informative, I must do work now :P