dshoreman / servidor

A modern web application for managing servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ProgressStep Wrapper Concept

dshoreman opened this issue · comments

ProgressStep could potentially be improved by taking a callback either in its constructor or a separate run() method (for example). It would allow us to send the ProjectProgress events automatically before/after executing the callback, rather than adding them manually for every step in the process.

// Consider this...
$step = new ProgressStep('nginx.reload', 'Reloading the nginx config');

$step->run(fn ($event) => {
    exec('systemctl reload-or-restart nginx.service');
});

// ...or even this...
(new ProgressStep('nginx.reload', 'Reloading the nginx config'))->run(fn ($event) => {
    exec('systemctl reload-or-restart nginx.service');
});

// ...vs this
ProjectProgress::dispatch($event->project, $step = new ProgressStep('nginx.reload', 'Reloading nginx service'));

exec('systemctl reload-or-restart nginx.service');

ProjectProgress::dispatch($event->project, $step->complete());