Automatically discovered system service called without arguments |
03-27-2022, 06:48 AM
(This post was last modified: 03-28-2022, 08:16 AM by mucio. Edit Reason: formatting )
Ohayo!
Being able to extend system services is a tremendously powerful feature that I'd like to use for fun and profit. So I went ahead and wrote this in my Services.php: PHP Code: public static function response(?App $config = null, $getShared = true): Response It appears, however, that the Response class expects a valid Config\App instance in its constructor. Not doing so results in many notices that shouldn't be ignored. When the service isn't overridden, the expected arguments are passed to BaseService::response and it works fine. But upon overriding the service (either from the app namespace or a custom one), the corresponding method is called without any arguments. I'm using the signature of the method as documented in system/Config/BaseService. All of this is really just to modify the send method so I can have my own emitting code.
I got it!
In order to override a service, you first have to copy the relevant method from system/Config/Services.php. So in this case it would be: PHP Code: public static function response(?App $config = null, bool $getShared = true) The emitting code does work fine though, I won't really need to re-implement it. |
Welcome Guest, Not a member yet? Register Sign In |