User configurable controller factory |
This is related to DI (dependency injection) but I want to make it clear up front that I am not just talking about DI i.e. this is not a duplicate of https://forum.codeigniter.com/thread-61345.html et al.
This is a subtly different feature request as implementing a user-configurable controller factory would permit end-users to implement DI differently if they wanted to do so. In CodeIgniter\CodeIgniter::createController() (framework/system/CodeIgniter.php) controllers are instantiated with the new keyword. If this was extracted to a factory class (perhaps resolvable via the Services configuration file) then end-users would be able to manage dependency injection for their controllers. A quick example implementation: PHP Code: /** With CodeIgniter\CodeIgniter::createController() altered to call this user-configurable factory: PHP Code: /** So far this would work exactly the same as the current controller instantiation but the instantiation has been moved into user space allowing end-users to instantiate controllers differently. An alternative implementation of the controllerFactory service might look like this: PHP Code: /** Or it could be quite different. The point being that it is user-configurable. Thoughts? |
Messages In This Thread |
User configurable controller factory - by Alex2005 - 05-17-2019, 01:25 PM
RE: User configurable controller factory - by kilishan - 05-17-2019, 01:51 PM
RE: User configurable controller factory - by Alex2005 - 05-18-2019, 01:16 AM
|