1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Sync\Db; |
4: | |
5: | use Salient\Contract\Core\Pipeline\ArrayMapperInterface; |
6: | use Salient\Contract\Core\Pipeline\PipelineInterface; |
7: | use Salient\Contract\Sync\EntitySource; |
8: | use Salient\Contract\Sync\FilterPolicy; |
9: | use Salient\Contract\Sync\SyncContextInterface; |
10: | use Salient\Contract\Sync\SyncEntityInterface; |
11: | use Salient\Contract\Sync\SyncOperation as OP; |
12: | use Salient\Core\Builder; |
13: | use Salient\Sync\Support\SyncPipelineArgument; |
14: | use Salient\Sync\AbstractSyncDefinition; |
15: | use Closure; |
16: | |
17: | /** |
18: | * @method $this operations(array<OP::*> $value) Supported sync operations |
19: | * @method $this table(?string $value) Set DbSyncDefinition::$Table |
20: | * @method $this conformity(DbSyncDefinition::* $value) Conformity level of data returned by the provider for this entity (see {@see AbstractSyncDefinition::$Conformity}) |
21: | * @method $this filterPolicy(FilterPolicy::*|null $value) Action to take when filters are not claimed by the provider (see {@see AbstractSyncDefinition::$FilterPolicy}) |
22: | * @method $this overrides(array<int-mask-of<OP::*>,Closure(DbSyncDefinition<TEntity,TProvider>, OP::*, SyncContextInterface, mixed...): (iterable<array-key,TEntity>|TEntity)> $value) Array that maps sync operations to closures that override other implementations (see {@see AbstractSyncDefinition::$Overrides}) |
23: | * @method $this keyMap(array<array-key,array-key|array-key[]>|null $value) Array that maps keys to properties for entity data returned by the provider (see {@see AbstractSyncDefinition::$KeyMap}) |
24: | * @method $this keyMapFlags(int-mask-of<ArrayMapperInterface::REMOVE_NULL|ArrayMapperInterface::ADD_UNMAPPED|ArrayMapperInterface::ADD_MISSING|ArrayMapperInterface::REQUIRE_MAPPED> $value) Array mapper flags used if a key map is provided |
25: | * @method $this readFromList(bool $value = true) Perform READ operations by iterating over entities returned by READ_LIST (default: false; see {@see AbstractSyncDefinition::$ReadFromList}) |
26: | * @method $this returnEntitiesFrom(EntitySource::*|null $value) Source of entity data for the return value of a successful CREATE, UPDATE or DELETE operation |
27: | * |
28: | * @template TEntity of SyncEntityInterface |
29: | * @template TProvider of DbSyncProvider |
30: | * |
31: | * @extends Builder<DbSyncDefinition<TEntity,TProvider>> |
32: | * |
33: | * @generated |
34: | */ |
35: | final class DbSyncDefinitionBuilder extends Builder |
36: | { |
37: | /** |
38: | * @internal |
39: | */ |
40: | protected static function getService(): string |
41: | { |
42: | return DbSyncDefinition::class; |
43: | } |
44: | |
45: | /** |
46: | * The entity being serviced |
47: | * |
48: | * @template T of SyncEntityInterface |
49: | * |
50: | * @param class-string<T> $value |
51: | * @return static<T,TProvider> |
52: | */ |
53: | public function entity(string $value) |
54: | { |
55: | /** @var static<T,TProvider> */ |
56: | return $this->withValueB(__FUNCTION__, $value); |
57: | } |
58: | |
59: | /** |
60: | * The provider servicing the entity |
61: | * |
62: | * @template T of DbSyncProvider |
63: | * |
64: | * @param T $value |
65: | * @return static<TEntity,T> |
66: | */ |
67: | public function provider(DbSyncProvider $value) |
68: | { |
69: | /** @var static<TEntity,T> */ |
70: | return $this->withValueB(__FUNCTION__, $value); |
71: | } |
72: | |
73: | /** |
74: | * Pipeline that maps provider data to a serialized entity, or `null` if mapping is not required |
75: | * |
76: | * @template T of SyncEntityInterface |
77: | * |
78: | * @param PipelineInterface<mixed[],T,SyncPipelineArgument>|null $value |
79: | * @return static<T,TProvider> |
80: | */ |
81: | public function pipelineFromBackend(?PipelineInterface $value) |
82: | { |
83: | /** @var static<T,TProvider> */ |
84: | return $this->withValueB(__FUNCTION__, $value); |
85: | } |
86: | |
87: | /** |
88: | * Pipeline that maps a serialized entity to provider data, or `null` if mapping is not required |
89: | * |
90: | * @template T of SyncEntityInterface |
91: | * |
92: | * @param PipelineInterface<T,mixed[],SyncPipelineArgument>|null $value |
93: | * @return static<T,TProvider> |
94: | */ |
95: | public function pipelineToBackend(?PipelineInterface $value) |
96: | { |
97: | /** @var static<T,TProvider> */ |
98: | return $this->withValueB(__FUNCTION__, $value); |
99: | } |
100: | } |
101: |