You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the Console extender's schedule method, it's currently required to pass an instantiated object (either a closure or an invokable class). Based on the docblock and patterns in other extenders, there's an expectation that the method should also accept the ::class syntax for invokable classes. However, this isn't currently supported, leading to unexpected behavior.
(newExtend\Console())
->schedule(Console\ProcessEraseRequests::class, Console\DailySchedule::class);
// Throws error: Call to undefined function Console\DailySchedule()
Steps to Reproduce
Create a new Console extender.
Use the schedule method with the ::class syntax for the callback.
Observe the error when the scheduled command is invoked.
Expected Behavior
(newExtend\Console())
->schedule(Console\ProcessEraseRequests::class, Console\DailySchedule::class);
// Should work, given that Console\DailySchedule is an invokable class
Output of "php flarum info", run this in terminal in your Flarum directory.
Possible Solution
Modify the Console extender to support both instantiated objects and the ::class syntax for invokable classes. This can be done using a similar approach to the Filesystem extender, utilizing the ContainerUtil::wrapCallback method.
Additional Context
This inconsistency can lead to confusion, especially given that other extenders in Flarum handle both closures and invokable classes correctly.
Tests should be added to ensure that this behavior is correctly implemented and maintained in the future.
The text was updated successfully, but these errors were encountered:
imorland
changed the title
[1.x] Support Invokable Classes in Console Extender's schedule method
Support Invokable Classes in Console Extender's schedule method
Oct 18, 2023
Current Behavior
When using the Console extender's schedule method, it's currently required to pass an instantiated object (either a closure or an invokable class). Based on the docblock and patterns in other extenders, there's an expectation that the method should also accept the ::class syntax for invokable classes. However, this isn't currently supported, leading to unexpected behavior.
Steps to Reproduce
Console
extender.Expected Behavior
Screenshots
No response
Environment
Output of
php flarum info
Possible Solution
Modify the
Console
extender to support both instantiated objects and the ::class syntax for invokable classes. This can be done using a similar approach to theFilesystem
extender, utilizing theContainerUtil::wrapCallback
method.Additional Context
This inconsistency can lead to confusion, especially given that other extenders in Flarum handle both closures and invokable classes correctly.
Tests should be added to ensure that this behavior is correctly implemented and maintained in the future.
The text was updated successfully, but these errors were encountered: