Skip to content

[11.x] Adds finally method to pipeline helper#54110

Merged
taylorotwell merged 3 commits into11.xfrom
feat/pipeline-finally
Jan 7, 2025
Merged

[11.x] Adds finally method to pipeline helper#54110
taylorotwell merged 3 commits into11.xfrom
feat/pipeline-finally

Conversation

@nunomaduro
Copy link
Copy Markdown
Member

This pull request adds the finally method to pipeline helper, so we can specify a callback to be executed regardless of the outcome of the pipeline.

This is the before:

try {
    $result = Pipeline::send($deployment)
        ->through([PipeOne::class, PipeTwo::class]) // one of the pipes does not call the $next or throws an exception...
        ->then(fn () => $deployment->deploy());
} finally {
    // perform clean up...
}

This is the after:

$result = Pipeline::send($deployment)
     ->through([PipeOne::class, PipeTwo::class]) // one of the pipes does not call the $next or throws an exception...
     ->finally(fn () => /** perform clean up */)
     ->then(fn () => $deployment->deploy());

@parijke
Copy link
Copy Markdown
Contributor

parijke commented Jan 7, 2025

Shouldn't the finally method be declared in https://github.com/laravel/framework/blob/11.x/src%2FIlluminate%2FSupport%2FFacades%2FPipeline.php as well?

@taylorotwell taylorotwell merged commit f80c63d into 11.x Jan 7, 2025
@taylorotwell taylorotwell deleted the feat/pipeline-finally branch January 7, 2025 23:29
@taylorotwell
Copy link
Copy Markdown
Member

@parijke our facades are updated automatically by a script.

@parijke
Copy link
Copy Markdown
Contributor

parijke commented Jan 8, 2025

@parijke our facades are updated automatically by a script.

That is cool @taylorotwell wow!

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

Successfully merging this pull request may close these issues.

4 participants