Methods |
public
|
registerNamespace(string $prefix, string $uri, string $namespace, ?SyncNamespaceHelperInterface $helper = null): $this
Register a namespace for sync entities and their provider interfaces
Register a namespace for sync entities and their provider interfaces
Namespaces allow sync entities to be serialized, linked and resolved via
compact, stable identifiers. They also allow control over the provider
interfaces that service sync entities.
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 in the backing database if they differ.
If $helper is null , the entity store assumes sync entities in
$namespace are serviced by provider interfaces called
<entity_namespace>\Provider\<entity>Provider , e.g. Sync\User entities
would be serviced by Sync\Provider\UserProvider . Provide a
{@see SyncNamespaceHelperInterface} 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
|
getNamespacePrefix(class-string<SyncEntityInterface|SyncProviderInterface> $class): ?string
Get a namespace prefix for a sync entity type or provider interface, or
null if it is not in a registered namespace
Get a namespace prefix for a sync entity type or provider interface, or
null if it is not in a registered namespace
Implemented by
|
#
|
public
|
getNamespaceHelper(class-string<SyncEntityInterface|SyncProviderInterface> $class): ?SyncNamespaceHelperInterface
Get a namespace helper for a sync entity type or provider interface, or
null if it is not in a namespace with a…
Get a namespace helper for a sync entity type or provider interface, or
null if it is not in a namespace with a registered helper
Implemented by
|
#
|
public
|
getProviderSignature(SyncProviderInterface $provider): string
Get a stable value that uniquely identifies a sync provider with the
entity store and is independent of its backing…
Get a stable value that uniquely identifies a sync provider with the
entity store and is independent of its backing database
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
|
hasProvider(SyncProviderInterface|string $provider): bool
Check if a sync provider is registered with the entity store
Check if a sync provider is registered with the entity store
Parameters
$provider |
A provider instance, or a
value returned by the store's
{@see SyncStoreInterface::getProviderSignature()} method.
|
Implemented by
|
#
|
public
|
getProviderId(SyncProviderInterface|string $provider): int
Get the provider ID by which a registered sync provider is uniquely
identified in the entity store's backing database
Get the provider ID by which a registered sync provider is uniquely
identified in the entity store's backing database
Parameters
$provider |
A provider instance, or a
value returned by the store's
{@see SyncStoreInterface::getProviderSignature()} method.
|
Throws
Implemented by
|
#
|
public
|
getProvider(string|int $provider): SyncProviderInterface
Get a sync provider registered with the entity store
Get a sync provider registered with the entity store
Parameters
$provider |
A provider ID, or a value returned by the
store's {@see SyncStoreInterface::getProviderSignature()} method.
|
Throws
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
|
registerEntityType(class-string<SyncEntityInterface> $entityType): $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
$entityType is case-sensitive and must exactly match the declared name
of the sync entity class.
Implemented by
|
#
|
public
|
hasEntityType(class-string<SyncEntityInterface> $entityType): bool
Check if a sync entity type is registered with the entity store
Check if a sync entity type is registered with the entity store
Implemented by
|
#
|
public
|
getEntityTypeId(class-string<SyncEntityInterface> $entityType): int
Get the entity type ID of a registered sync entity type
Get the entity type ID of a registered sync entity type
Throws
Implemented by
|
#
|
public
|
getEntityType(int $entityTypeId): class-string<SyncEntityInterface>
Get a sync entity type registered with the entity store
Get a sync entity type registered with the entity store
Throws
Implemented by
|
#
|
public
|
getEntityTypeUri(class-string<SyncEntityInterface> $entityType, bool $compact = true): string
Get the canonical URI of a sync entity type
Get the canonical URI of a sync entity type
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
|
#
|