22
33### Sync providers
44
5- A sync provider is a class that implements [ ISyncProvider ] [ ] and performs one or
6- more [ sync operations] [ SyncOperation ] on supported [ entity classes ] [ ISyncEntity ]
7- to propagate data to and from a backend.
5+ A sync provider is a class that implements [ SyncProviderInterface ] [ ] and
6+ performs one or more [ sync operations] [ SyncOperation ] on supported [ entity
7+ classes ] [ SyncEntityInterface ] to propagate data to and from a backend.
88
99For a provider to perform sync operations on entities of a given type, it must
1010also implement the entity's provider interface. Aside from entities in
11- namespaces registered with a [ class resolver] [ ISyncClassResolver ] , the provider
12- interface is assumed to be:
11+ namespaces registered with a [ class resolver] [ SyncClassResolverInterface ] , the
12+ provider interface is assumed to be:
1313
1414```
1515<entity-namespace>\Provider\<entity>Provider
@@ -30,34 +30,34 @@ vendor/bin/lk-util generate sync provider --magic --op 'get,get-list' 'Acme\Sync
3030#### Class resolvers
3131
3232To map entity classes to different provider interfaces (or multiple entities to
33- one interface, perhaps), you can provide an [ ISyncClassResolver ] [ ] to the entity
34- store when registering a namespace. See [ Sync::namespace()] [ namespace ] for
35- details and [ this test fixture] [ SyncClassResolver.php ] for a working example
33+ one interface, perhaps), you can provide a [ SyncClassResolverInterface ] [ ] to the
34+ entity store when registering a namespace. See [ Sync::namespace()] [ namespace ]
35+ for details and [ this test fixture] [ SyncClassResolver.php ] for a working example
3636that would map ` Acme\Sync\Entity\User ` to ` Acme\Sync\Contract\ProvidesUser ` .
3737
3838#### Operations
3939
40- To perform a sync operation on an [ entity] [ ISyncEntity ] , an [ ISyncProvider ] [ ]
41- must implement its provider interface and either:
40+ To perform a sync operation on an [ entity] [ SyncEntityInterface ] , a
41+ [ SyncProviderInterface ] [ ] must implement its provider interface and either:
4242
43431 . return a closure for the [ SyncOperation] [ ] and entity via
4444 [ getDefinition()] [ getDefinition ] , or
45452 . declare a method for the operation using the naming convention below.
4646
4747In either case, the signature for the implemented operation must be as follows.
48- The first value passed is always the current [ ISyncContext ] and ** optional **
49- arguments may be accepted after mandatory parameters.
50-
51- | Operation[ ^ op ] | Closure signature | Equivalent method[ ^ 1 ] | Alternative method[ ^ 2 ] |
52- | --------------- | --------------------------------------------------------------------- | ------------------------ | ---------------------- |
53- | ` CREATE ` | ` fn(ISyncContext $ctx, ISyncEntity $entity, ...$args): ISyncEntity ` | ` create<EntitySingular> ` | ` create_<Entity> ` |
54- | ` READ ` | ` fn(ISyncContext $ctx, int\|string\|null $id, ...$args): ISyncEntity ` | ` get<EntitySingular> ` | ` get_<Entity> ` |
55- | ` UPDATE ` | ` fn(ISyncContext $ctx, ISyncEntity $entity, ...$args): ISyncEntity ` | ` update<EntitySingular> ` | ` update_<Entity> ` |
56- | ` DELETE ` | ` fn(ISyncContext $ctx, ISyncEntity $entity, ...$args): ISyncEntity ` | ` delete<EntitySingular> ` | ` delete_<Entity> ` |
57- | ` CREATE_LIST ` | ` fn(ISyncContext $ctx, iterable $entities, ...$args): iterable ` | ` create<EntityPlural> ` | ` createList_<Entity> ` |
58- | ` READ_LIST ` [ ^ 3 ] | ` fn(ISyncContext $ctx, ...$args): iterable ` | ` get<EntityPlural> ` | ` getList_<Entity> ` |
59- | ` UPDATE_LIST ` | ` fn(ISyncContext $ctx, iterable $entities, ...$args): iterable ` | ` update<EntityPlural> ` | ` updateList_<Entity> ` |
60- | ` DELETE_LIST ` | ` fn(ISyncContext $ctx, iterable $entities, ...$args): iterable ` | ` delete<EntityPlural> ` | ` deleteList_<Entity> ` |
48+ The first value passed is always the current [ SyncContextInterface ] and
49+ ** optional ** arguments may be accepted after mandatory parameters.
50+
51+ | Operation[ ^ op ] | Closure signature | Equivalent method[ ^ 1 ] | Alternative method[ ^ 2 ] |
52+ | --------------- | ------------------------------------------------------------------------------------------- | ------------------------ | ---------------------- |
53+ | ` CREATE ` | ` fn(SyncContextInterface $ctx, SyncEntityInterface $entity, ...$args): SyncEntityInterface ` | ` create<EntitySingular> ` | ` create_<Entity> ` |
54+ | ` READ ` | ` fn(SyncContextInterface $ctx, int\|string\|null $id, ...$args): SyncEntityInterface ` | ` get<EntitySingular> ` | ` get_<Entity> ` |
55+ | ` UPDATE ` | ` fn(SyncContextInterface $ctx, SyncEntityInterface $entity, ...$args): SyncEntityInterface ` | ` update<EntitySingular> ` | ` update_<Entity> ` |
56+ | ` DELETE ` | ` fn(SyncContextInterface $ctx, SyncEntityInterface $entity, ...$args): SyncEntityInterface ` | ` delete<EntitySingular> ` | ` delete_<Entity> ` |
57+ | ` CREATE_LIST ` | ` fn(SyncContextInterface $ctx, iterable $entities, ...$args): iterable ` | ` create<EntityPlural> ` | ` createList_<Entity> ` |
58+ | ` READ_LIST ` [ ^ 3 ] | ` fn(SyncContextInterface $ctx, ...$args): iterable ` | ` get<EntityPlural> ` | ` getList_<Entity> ` |
59+ | ` UPDATE_LIST ` | ` fn(SyncContextInterface $ctx, iterable $entities, ...$args): iterable ` | ` update<EntityPlural> ` | ` updateList_<Entity> ` |
60+ | ` DELETE_LIST ` | ` fn(SyncContextInterface $ctx, iterable $entities, ...$args): iterable ` | ` delete<EntityPlural> ` | ` deleteList_<Entity> ` |
6161
6262[ ^ op ] : See [ SyncOperation] .
6363[ ^ 1 ] :
@@ -69,23 +69,23 @@ arguments may be accepted after mandatory parameters.
6969 Method names must match the entity's unqualified name.
7070
7171[ ^ 3 ] :
72- See [ ISyncContext ::withArgs()] [ withArgs ] for filter argument
72+ See [ SyncContextInterface ::withArgs()] [ withArgs ] for filter argument
7373 recommendations, including recognised signatures.
7474
7575[ getDefinition] :
76- https://lkrms.github.io/php-util/Lkrms .Sync.Contract.ISyncProvider .html#_getDefinition
77- [ ISyncContext ] :
78- https://lkrms.github.io/php-util/Lkrms .Sync.Contract.ISyncContext .html
79- [ ISyncEntity ] :
80- https://lkrms.github.io/php-util/Lkrms .Sync.Contract.ISyncEntity .html
81- [ ISyncProvider ] :
82- https://lkrms.github.io/php-util/Lkrms .Sync.Contract.ISyncProvider .html
83- [ ISyncClassResolver ] :
84- https://lkrms.github.io/php-util/Lkrms .Sync.Contract.ISyncClassResolver .html
76+ https://lkrms.github.io/php-util/Salient .Sync.Contract.SyncProviderInterface .html#_getDefinition
77+ [ SyncContextInterface ] :
78+ https://lkrms.github.io/php-util/Salient .Sync.Contract.SyncContextInterface .html
79+ [ SyncEntityInterface ] :
80+ https://lkrms.github.io/php-util/Salient .Sync.Contract.SyncEntityInterface .html
81+ [ SyncProviderInterface ] :
82+ https://lkrms.github.io/php-util/Salient .Sync.Contract.SyncProviderInterface .html
83+ [ SyncClassResolverInterface ] :
84+ https://lkrms.github.io/php-util/Salient .Sync.Contract.SyncClassResolverInterface .html
8585[ SyncOperation] :
86- https://lkrms.github.io/php-util/Lkrms .Sync.Catalog.SyncOperation.html
86+ https://lkrms.github.io/php-util/Salient .Sync.Catalog.SyncOperation.html
8787[ withArgs] :
88- https://lkrms.github.io/php-util/Lkrms .Sync.Contract.ISyncContext .html#_withArgs
88+ https://lkrms.github.io/php-util/Salient .Sync.Contract.SyncContextInterface .html#_withArgs
8989[ namespace] :
90- https://lkrms.github.io/php-util/Lkrms .Sync.Support .SyncStore.html#_namespace
91- [ SyncClassResolver.php ] : ../tests/fixtures/Util /Sync/SyncClassResolver.php
90+ https://lkrms.github.io/php-util/Salient .Sync.SyncStore.html#_namespace
91+ [ SyncClassResolver.php ] : ../tests/fixtures/Toolkit /Sync/SyncClassResolver.php
0 commit comments