Methods |
public
|
__construct(string $filename = ':memory:', string $command = '', string[] $arguments = [])
Creates a new SyncStore object
Creates a new SyncStore object
Parameters
$command |
The canonical name of the command performing sync
operations (e.g. a qualified class and/or method name).
|
$arguments |
Arguments passed to the command.
|
Implements
|
#
|
public
|
close(int $exitStatus = 0): void
Terminate the current run and close the database
Terminate the current run and close the database
Overrides
|
#
|
public
|
runHasStarted(): bool
Check if a run of sync operations has started
Check if a run of sync operations has started
Implements
|
#
|
public
|
getRunId(): int
Get the run ID of the current run
Get the run ID of the current run
Implements
|
#
|
public
|
getRunUuid(): string
Get the UUID of the current run in hexadecimal form
Get the UUID of the current run in hexadecimal form
Implements
|
#
|
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
Implements
|
#
|
public
|
registerProvider(SyncProviderInterface $provider)
Register a sync provider with the entity store
Register a sync provider with the entity store
Implements
|
#
|
public
|
hasProvider($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.
|
Implements
|
#
|
public
|
getProviderId($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.
|
Implements
|
#
|
public
|
getProvider($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.
|
Implements
|
#
|
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
Implements
|
#
|
public
|
registerEntityType(string $entityType)
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.
Implements
|
#
|
public
|
hasEntityType(string $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
Implements
|
#
|
public
|
getEntityTypeId(string $entityType): int
Get the entity type ID of a registered sync entity type
Get the entity type ID of a registered sync entity type
Implements
|
#
|
public
|
getEntityType(int $entityTypeId): string
Get a sync entity type registered with the entity store
Get a sync entity type registered with the entity store
Implements
|
#
|
public
|
registerNamespace(string $prefix, string $uri, string $namespace, ?SyncNamespaceHelperInterface $helper = null)
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.
|
Implements
|
#
|
public
|
getEntityTypeUri(string $entityType, bool $compact = true): string
Get the canonical URI of a sync entity type
Get the canonical URI of a sync entity type
Implements
|
#
|
public
|
getNamespacePrefix(string $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
Implements
|
#
|
public
|
getNamespaceHelper(string $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
Implements
|
#
|
public
|
setEntity(int $providerId, string $entityType, $entityId, SyncEntityInterface $entity)
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
Implements
|
#
|
public
|
getEntity<TEntity is SyncEntityInterface>(
int $providerId,
class-string<TEntity> $entityType,
$entityId,
?bool $offline = null,
): TEntity|null
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
|
Implements
|
#
|
public
|
deferEntity<TEntity is SyncEntityInterface>(
int $providerId,
class-string<TEntity> $entityType,
$entityId,
DeferredEntityInterface<TEntity> $entity,
)
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.
Implements
|
#
|
public
|
deferRelationship(
int $providerId,
string $entityType,
string $forEntityType,
string $forEntityProperty,
$forEntityId,
DeferredRelationshipInterface $relationship,
)
Register a deferred relationship with the entity store
Register a deferred relationship with the entity store
Implements
|
#
|
public
|
resolveDeferrals(?int $fromCheckpoint = null, ?string $entityType = null, ?int $providerId = null): array
Resolve deferred entities and relationships recursively until no
deferrals remain
Resolve deferred entities and relationships recursively until no
deferrals remain
Implements
|
#
|
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.
Implements
|
#
|
public
|
resolveDeferredEntities(?int $fromCheckpoint = null, ?string $entityType = null, ?int $providerId = null): array
Resolve deferred entities
Resolve deferred entities
Implements
|
#
|
public
|
resolveDeferredRelationships(
?int $fromCheckpoint = null,
?string $entityType = null,
?string $forEntityType = null,
?string $forEntityProperty = null,
?int $providerId = null,
): array
Resolve deferred relationships
Resolve deferred relationships
Implements
|
#
|
public
|
checkProviderHeartbeats(int $ttl = 300, bool $failEarly = true, SyncProviderInterface ...$providers)
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.
Implements
|
#
|
public
|
recordError(SyncErrorInterface $error, bool $deduplicate = false)
Register a non-fatal sync operation error with the entity store
Register a non-fatal sync operation error with the entity store
Implements
|
#
|
public
|
getErrors(): SyncErrorCollectionInterface
Get sync operation errors recorded so far
Get sync operation errors recorded so far
Implements
|
#
|
protected
|
check()
Override to perform an action whenever the underlying SQLite3 instance is
accessed
Override to perform an action whenever the underlying SQLite3 instance is
accessed
Called once per call to {@see AbstractStore::db()}. Use
{@see AbstractStore::safeCheck()} to prevent recursion if necessary.
Overrides
|
#
|