1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Sync;
4:
5: use Salient\Contract\Core\Immutable;
6: use Salient\Contract\Sync\SyncOperation as OP;
7: use Closure;
8:
9: /**
10: * Provides direct access to a provider's implementation of sync operations for
11: * an entity
12: *
13: * @template TEntity of SyncEntityInterface
14: * @template TProvider of SyncProviderInterface
15: */
16: interface SyncDefinitionInterface extends Immutable
17: {
18: /**
19: * Get a closure to perform a sync operation on the entity, or null if the
20: * operation is not supported
21: *
22: * @template TOperation of OP::*
23: *
24: * @param TOperation $operation
25: * @return (
26: * TOperation is OP::READ
27: * ? (Closure(SyncContextInterface, int|string|null, mixed...): TEntity)
28: * : (
29: * TOperation is OP::READ_LIST
30: * ? (Closure(SyncContextInterface, mixed...): iterable<TEntity>)
31: * : (
32: * TOperation is OP::CREATE|OP::UPDATE|OP::DELETE
33: * ? (Closure(SyncContextInterface, TEntity, mixed...): TEntity)
34: * : (Closure(SyncContextInterface, iterable<TEntity>, mixed...): iterable<TEntity>)
35: * )
36: * )
37: * )|null
38: */
39: public function getOperationClosure(int $operation): ?Closure;
40: }
41: