1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Sync;
4:
5: use Salient\Contract\Container\ContainerInterface;
6: use Salient\Contract\Core\ProviderInterface;
7:
8: /**
9: * Base interface for providers that sync entities to and from third-party
10: * backends
11: *
12: * @extends ProviderInterface<SyncContextInterface>
13: */
14: interface SyncProviderInterface extends ProviderInterface
15: {
16: /**
17: * @inheritDoc
18: */
19: public function getContext(?ContainerInterface $container = null): SyncContextInterface;
20:
21: /**
22: * Get the provider ID assigned to the backend instance by its entity store
23: */
24: public function getProviderId(): int;
25:
26: /**
27: * Get the provider's implementation of sync operations for an entity
28: *
29: * @template T of SyncEntityInterface
30: *
31: * @param class-string<T> $entity
32: * @return SyncDefinitionInterface<T,$this>
33: */
34: public function getDefinition(string $entity): SyncDefinitionInterface;
35:
36: /**
37: * Get the provider's default unclaimed filter policy
38: *
39: * @return FilterPolicy::*|null
40: */
41: public function getFilterPolicy(): ?int;
42:
43: /**
44: * True if a value is of the correct type and format to be an entity ID
45: *
46: * @param int|string $id
47: * @param class-string<SyncEntityInterface> $entity
48: */
49: public function isValidIdentifier($id, string $entity): bool;
50:
51: /**
52: * Get the provider's entity store
53: */
54: public function getStore(): SyncStoreInterface;
55:
56: /**
57: * Use an entity-agnostic interface to the provider's implementation of sync
58: * operations for an entity
59: *
60: * @template T of SyncEntityInterface
61: *
62: * @param class-string<T> $entity
63: * @return SyncEntityProviderInterface<T>
64: */
65: public function with(string $entity, ?SyncContextInterface $context = null): SyncEntityProviderInterface;
66: }
67: