-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1111: [Interceptors] Add PipelineBuilder
- Loading branch information
Showing
26 changed files
with
417 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spiral\Core; | ||
|
||
use Psr\EventDispatcher\EventDispatcherInterface; | ||
use Spiral\Interceptors\HandlerInterface; | ||
use Spiral\Interceptors\InterceptorInterface; | ||
use Spiral\Interceptors\PipelineBuilderInterface; | ||
|
||
/** | ||
* Accepts {@see InterceptorInterface} and {@see CoreInterface} instances to build a pipeline. | ||
* | ||
* @deprecated Use {@see PipelineBuilder} instead. | ||
*/ | ||
class CompatiblePipelineBuilder implements PipelineBuilderInterface | ||
{ | ||
private InterceptorPipeline $pipeline; | ||
|
||
public function __construct(?EventDispatcherInterface $dispatcher = null) | ||
{ | ||
$this->pipeline = new InterceptorPipeline($dispatcher); | ||
} | ||
|
||
public function __clone() | ||
{ | ||
$this->pipeline = clone $this->pipeline; | ||
} | ||
|
||
public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static | ||
{ | ||
$clone = clone $this; | ||
foreach ($interceptors as $interceptor) { | ||
$clone->pipeline->addInterceptor($interceptor); | ||
} | ||
|
||
return $clone; | ||
} | ||
|
||
public function build(HandlerInterface|CoreInterface $last): InterceptorPipeline | ||
{ | ||
/** @psalm-suppress InvalidArgument */ | ||
return $last instanceof HandlerInterface | ||
? $this->pipeline->withHandler($last) | ||
: $this->pipeline->withCore($last); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.