Methods |
public
|
registerNamespace(string $prefix, string $uri, string $namespace, ?SyncClassResolverInterface $resolver = null): $this
Register a namespace for sync entities and their provider interfaces
Register a namespace for sync entities and their provider interfaces
A prefix can only be associated with one namespace per entity store and
cannot be changed without resetting its backing database.
If $prefix was registered on a previous run, its URI and PHP namespace
are updated if they differ. This is by design and is intended to
facilitate refactoring.
If $resolver is null , the entity store assumes sync entities in
$namespace are serviced by provider interfaces called
<entity-namespace>\Provider\<entity>Provider , e.g. Acme\Sync\User
entities would be serviced by Acme\Sync\Provider\UserProvider . Provide
a {@see SyncClassResolverInterface} to modify this behaviour.
Parameters
$prefix |
A short alternative to $uri . Case-insensitive.
Must be unique to the entity store. Must be a scheme name compliant with
Section 3.1 of [RFC3986], i.e. a match for the regular expression
^[a-zA-Z][a-zA-Z0-9+.-]*$ .
|
$uri |
A globally unique namespace URI.
|
$namespace |
The PHP namespace that contains sync entity
classes and their respective provider interfaces.
|
Throws
Implemented by
|
#
|
public
|
getClassResolver(class-string<SyncEntityInterface|SyncProviderInterface> $class): ?SyncClassResolverInterface
Get a class resolver for a sync entity or provider interface, or null if
it is not in a namespace with a registered…
Get a class resolver for a sync entity or provider interface, or null if
it is not in a namespace with a registered resolver
Implemented by
|
#
|
public
|
getProviderSignature(SyncProviderInterface $provider): string
Get a stable value that uniquely identifies a sync provider with the
entity store
Get a stable value that uniquely identifies a sync provider with the
entity store
Implemented by
|
#
|
public
|
registerProvider(SyncProviderInterface $provider): $this
Register a sync provider with the entity store
Register a sync provider with the entity store
Throws
Implemented by
|
#
|
public
|
getProviderId(SyncProviderInterface $provider): int
Get the provider ID of a registered sync provider
Get the provider ID of a registered sync provider
Throws
Implemented by
|
#
|
public
|
getProvider(string $signature): ?SyncProviderInterface
Get a sync provider if it is registered with the entity store
Get a sync provider if it is registered with the entity store
Implemented by
|
#
|
public
|
checkProviderHeartbeats(int $ttl = 300, bool $failEarly = true, SyncProviderInterface ...$providers): $this
Throw an exception if a sync provider's backend is unreachable
Throw an exception if a sync provider's backend is unreachable
If no providers are given, every provider registered with the entity
store is checked.
If the same provider is given multiple times, it is only checked once.
{@see MethodNotImplementedExceptionInterface} exceptions thrown by
{@see ProviderInterface::checkHeartbeat()} are caught and ignored.
Throws
Implemented by
|
#
|
public
|
registerEntity(class-string<SyncEntityInterface> $entity): $this
Register a sync entity type with the entity store if it is not already
registered
Register a sync entity type with the entity store if it is not already
registered
$entity is case-sensitive and must exactly match the declared name of
the sync entity class.
Implemented by
|
#
|
public
|
getEntityId(class-string<SyncEntityInterface> $entity): int
Get the entity ID of a registered sync entity type
Get the entity ID of a registered sync entity type
Throws
Implemented by
|
#
|
public
|
getEntityUri(class-string<SyncEntityInterface> $entity, bool $compact = true): ?string
Get the canonical URI of a sync entity, or null if it is not in a
registered namespace
Get the canonical URI of a sync entity, or null if it is not in a
registered namespace
Implemented by
|
#
|
public
|
getEntityPrefix(class-string<SyncEntityInterface> $entity): ?string
Get the prefix of a sync entity's namespace, or null if it is not in a
registered namespace
Get the prefix of a sync entity's namespace, or null if it is not in a
registered namespace
Implemented by
|
#
|
public
|
setEntity(
int $providerId,
class-string<SyncEntityInterface> $entityType,
int|string $entityId,
SyncEntityInterface $entity,
): $this
Apply a sync entity retrieved from a provider to the entity store,
resolving any matching deferred entities
Apply a sync entity retrieved from a provider to the entity store,
resolving any matching deferred entities
Throws
LogicException |
if the entity has already been applied to the
entity store or retrieved via {@see SyncStoreInterface::getEntity()} in
the current run.
|
Implemented by
|
#
|
public
|
getEntity(
int $providerId,
class-string<SyncEntityInterface> $entityType,
int|string $entityId,
bool|null $offline = null,
): ?SyncEntityInterface
Get a sync entity from the entity store if it is available
Get a sync entity from the entity store if it is available
Parameters
$offline |
-
null (default) or true : allow the entity
to be retrieved from the local entity store
-
false : do not retrieve the entity from the local entity store; return
null if it has not been applied to the store in the current run
|
Implemented by
|
#
|
public
|
deferEntity<TEntity is SyncEntityInterface>(
int $providerId,
class-string<TEntity> $entityType,
int|string $entityId,
DeferredEntityInterface<TEntity> $entity,
): $this
Register a deferred entity with the entity store
Register a deferred entity with the entity store
If a matching entity has already been applied to the entity store, the
deferred entity is resolved immediately, otherwise it is queued for
retrieval from the provider.
Implemented by
|
#
|
public
|
deferRelationship<TEntity is SyncEntityInterface>(
int $providerId,
class-string<TEntity> $entityType,
class-string<SyncEntityInterface> $forEntityType,
string $forEntityProperty,
int|string $forEntityId,
DeferredRelationshipInterface<TEntity> $relationship,
): $this
Register a deferred relationship with the entity store
Register a deferred relationship with the entity store
Implemented by
|
#
|
public
|
getDeferralCheckpoint(): int
Get a checkpoint to delineate between deferred entities and relationships
that have already been registered, and any…
Get a checkpoint to delineate between deferred entities and relationships
that have already been registered, and any subsequent deferrals
The value returned by this method can be used to limit the scope of
{@see SyncStoreInterface::resolveDeferrals()},
{@see SyncStoreInterface::resolveDeferredEntities()} and
{@see SyncStoreInterface::resolveDeferredRelationships()}, e.g. to
entities and relationships deferred during a particular operation.
Implemented by
|
#
|
public
|
resolveDeferrals(
?int $fromCheckpoint = null,
class-string<SyncEntityInterface>|null $entityType = null,
?int $providerId = null,
): SyncEntityInterface[]
Resolve deferred entities and relationships recursively until no
deferrals remain
Resolve deferred entities and relationships recursively until no
deferrals remain
Implemented by
|
#
|
public
|
resolveDeferredEntities(
?int $fromCheckpoint = null,
class-string<SyncEntityInterface>|null $entityType = null,
?int $providerId = null,
): SyncEntityInterface[]
Resolve deferred entities
Resolve deferred entities
Implemented by
|
#
|
public
|
resolveDeferredRelationships(
?int $fromCheckpoint = null,
class-string<SyncEntityInterface>|null $entityType = null,
class-string<SyncEntityInterface>|null $forEntityType = null,
?string $forEntityProperty = null,
?int $providerId = null,
): SyncEntityInterface[][]
Resolve deferred relationships
Resolve deferred relationships
Implemented by
|
#
|
public
|
runHasStarted(): bool
Check if a run of sync operations has started
Check if a run of sync operations has started
Implemented by
|
#
|
public
|
getRunId(): int
Get the run ID of the current run
Get the run ID of the current run
Throws
Implemented by
|
#
|
public
|
getRunUuid(): string
Get the UUID of the current run in hexadecimal form
Get the UUID of the current run in hexadecimal form
Throws
Implemented by
|
#
|
public
|
getBinaryRunUuid(): string
Get the UUID of the current run in raw binary form
Get the UUID of the current run in raw binary form
Throws
Implemented by
|
#
|
public
|
recordError(SyncErrorInterface $error, bool $deduplicate = false): $this
Register a non-fatal sync operation error with the entity store
Register a non-fatal sync operation error with the entity store
Implemented by
|
#
|
public
|
getErrors(): SyncErrorCollectionInterface
Get sync operation errors recorded so far
Get sync operation errors recorded so far
Implemented by
|
#
|