Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propose: Allow execute functions #13

Closed
crhdev opened this issue Sep 11, 2024 · 2 comments
Closed

propose: Allow execute functions #13

crhdev opened this issue Sep 11, 2024 · 2 comments

Comments

@crhdev
Copy link

crhdev commented Sep 11, 2024

Hello, in this commit: crhdev@83b5841 , I was playing a little to be able to allow the execution of functions instead of cake command. In my application, I have some use cases where creating a command is unnecessary. Do you think it may be possible to integrate something like this?

    public function schedule(Scheduler &$scheduler): void
    {
        $scheduler->execute(function($a, $b, $c, ConsoleIo $io) {
            $io->info('Sum');
            return $a + $b + $c;
        }, [1,2,3])->everyXMinutes(1);
    }
@LordSimal
Copy link
Owner

So you don't test these kind of functions?

I don't really like breaking this kind of structure since commands are really easy to make via bin/cake bake command and thats it.

Especially since all that Command class needs to have is the execute method. You can just remove the buildOptionParser method if you don't need it.

@crhdev
Copy link
Author

crhdev commented Sep 12, 2024

Sorry, the example I gave was basic.
Maybe something like:

 public function schedule(Scheduler &$scheduler): void
    {
        $scheduler->execute(function($a, $b, $c, ConsoleIo $io) {
            $service = new CriticalRenewAuditLog();
            return $service->run($a, $b, $c);
        }, [1,2,3])->everyXMinutes(1);
    }

In this case, we have a test for CriticalRenewAuditLog class.

For some security reasons (that I don't know), in my team, it is not allowed to create cake commands for certain things since they could be invoked by other parts of the development team, for example the 'system administrators', since they can log in the container/server/whatever and execute them by hand with ./bin/cake etc...

LordSimal added a commit that referenced this issue Sep 12, 2024
LordSimal added a commit that referenced this issue Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants