Skip to content

Commit c3ce2f0

Browse files
committed
Merge branch 'sync-pipelines'
2 parents ec81f59 + cf4ece3 commit c3ce2f0

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/Sync/Concept/SyncProvider.php

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Lkrms\Contract\IService;
99
use Lkrms\Support\Catalog\RegularExpression as Regex;
1010
use Lkrms\Support\Pipeline;
11+
use Lkrms\Sync\Catalog\SyncOperation as OP;
1112
use Lkrms\Sync\Contract\ISyncContext;
1213
use Lkrms\Sync\Contract\ISyncEntity;
1314
use Lkrms\Sync\Contract\ISyncProvider;
@@ -191,20 +192,46 @@ protected function run(ISyncContext $context, callable $operation)
191192
}
192193

193194
/**
194-
* Get a new pipeline bound to the provider's container
195+
* Get a new pipeline for mapping provider data to entities
195196
*
197+
* @template T of ISyncEntity
198+
* @param class-string<T> $entity
199+
* @return IPipeline<mixed[],T,array{0:OP::*,1:ISyncContext,2?:int|string|T|T[]|null,...}>
200+
*/
201+
protected function pipelineFrom(string $entity): IPipeline
202+
{
203+
return Pipeline::create($this->App);
204+
}
205+
206+
/**
207+
* Get a new pipeline for mapping entities to provider data
208+
*
209+
* @template T of ISyncEntity
210+
* @param class-string<T> $entity
211+
* @return IPipeline<T,mixed[],array{0:OP::*,1:ISyncContext,2?:int|string|T|T[]|null,...}>
212+
*/
213+
protected function pipelineTo(string $entity): IPipeline
214+
{
215+
return Pipeline::create($this->App);
216+
}
217+
218+
/**
196219
* @return IPipeline<mixed,mixed,mixed>
220+
* @deprecated Use {@see SyncProvider::pipelineFrom()} or
221+
* {@see SyncProvider::pipelineTo()} instead
222+
* @codeCoverageIgnore
197223
*/
198224
protected function pipeline(): IPipeline
199225
{
200226
return Pipeline::create($this->App);
201227
}
202228

203229
/**
204-
* Wrap a new pipeline around a callback
205-
*
206230
* @param (callable(mixed $payload, IPipeline<mixed,mixed,mixed> $pipeline, mixed $arg): mixed) $callback
207231
* @return IPipeline<mixed,mixed,mixed>
232+
* @deprecated Use {@see SyncProvider::pipelineFrom()} or
233+
* {@see SyncProvider::pipelineTo()} instead
234+
* @codeCoverageIgnore
208235
*/
209236
protected function callbackPipeline(callable $callback): IPipeline
210237
{

0 commit comments

Comments
 (0)