nightjarnz

otherwise you'll need to call new YourClass($widthParameter) as with normal PHP.

nightjarnz

but if you do the above, you MUST instantiate all your classes with Injector::inst()->create(YourClass::class)

nightjarnz

where the constructor looks like __construct($width) you can use

  1. YourClass:
  2. constructor:
  3. width: 40

The constructor: yaml property takes an array. But because PHP arrays and keyed arrays are the same (as opposed to JavaScript), you can key the array in a sort of self-documenting style. Be aware though, the order is important - the key means nothing.

nightjarnz

OR in a cheeky combination of the second point I made above

nightjarnz

ok, so there are 2 ways of achieving this :P one is to change e.g.

  1. function __construct()
  2. {
  3. $width = self::config()->get('width');
  4. }

to instead be more like:

  1. function __construct($width = null)
  2. {
  3. $width = $width ?: self::config()->get('width');
  4. }

This way you can create objects in PHP without messing around withe the global configuration (if one should ever need to). Plus the internal object state is less magic.

Batsis

Thanks @Firesphere & @nightjarnz. I have resolved it by escalating the project's priority for now. @nightjarnz if you can please explain number 1 a bit that will be awesome.

Batsis

@Firesphere I am overriding userform templates in my module for which I had to add Before: #module-other