This accepts an indexed array of class names and returns an associative array where the key is the service's class name and the value is the instantiated Service object. Generally, this is what we want - it keeps Service object instantiation simple and eliminates any immediate need for dependencies.
That said, there may be situations where our Service classes might be more complex, and we want to pass a shared dependency into multiple Service objects. In those situations, we may want fine-tuned control over how our Service objects are created, either via use of a dependency injection conatiner such as Auryn, or some other method. In those cases, we'll need to override this method, which is not currently possible due to its private visibility. An example override might look like this:
It's a subtle difference - the only actual change here is how the object is instantiated. However, having the flexibility for that change makes an enormous difference.
Use case:
In 0.2.0, the
init_services
method looks like this:This accepts an indexed array of class names and returns an associative array where the key is the service's class name and the value is the instantiated Service object. Generally, this is what we want - it keeps Service object instantiation simple and eliminates any immediate need for dependencies.
That said, there may be situations where our Service classes might be more complex, and we want to pass a shared dependency into multiple Service objects. In those situations, we may want fine-tuned control over how our Service objects are created, either via use of a dependency injection conatiner such as Auryn, or some other method. In those cases, we'll need to override this method, which is not currently possible due to its private visibility. An example override might look like this:
It's a subtle difference - the only actual change here is how the object is instantiated. However, having the flexibility for that change makes an enormous difference.