<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class WorkflowRollbackCommand extends AbstractCommand
{
    public function name(): string { return 'workflow:rollback'; }
    public function description(): string { return 'PPphp Workflow Rollback'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Workflow Rollback');
        $runtime = \PpPhp\Core\Platform\Workflow\Compensation\WorkflowCompensationRuntime::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); $runtime->registerPlan(\PpPhp\Core\Platform\Workflow\Compensation\WorkflowCompensationPlan::create('console_workflow', [\PpPhp\Core\Platform\Workflow\Compensation\WorkflowCompensationAction::create('console_workflow', 'console_step', 'undo_console_step')->toArray()])); $executed = $runtime->rollback(\PpPhp\Core\Platform\Workflow\Compensation\WorkflowRollbackRequest::create('console_workflow', 'console-workflow-instance', ['console_step'], 'console rollback')); $this->line('Rolled Back: ' . $executed);
        return 0;
    }
}
