Methods |
public
|
pushEntity($entity, bool $detectRecursion = false)
Parameters
$detectRecursion |
If true , check if the context has already
been propagated for $entity and return the result via
{@see SyncContextInterface::recursionDetected()}.
|
|
#
|
public
|
recursionDetected(): bool
Check if recursion was detected during the last call to pushEntity()
Check if recursion was detected during the last call to pushEntity()
Implemented by
|
#
|
public
|
hasOperation(): bool
Check if a sync operation has been applied to the context
Check if a sync operation has been applied to the context
Implemented by
|
#
|
public
|
getOperation(): SyncOperation::*|null
Get the sync operation applied to the context
Get the sync operation applied to the context
Implemented by
|
#
|
public
|
hasFilter(string|null $key = null): bool
Check if the context has an unclaimed filter applied via non-mandatory
sync operation arguments
Check if the context has an unclaimed filter applied via non-mandatory
sync operation arguments
Parameters
$key |
If null , check if the context has any unclaimed
filters.
|
Implemented by
|
#
|
public
|
getFilter(string $key, bool $orValue = true): (int|string|float|bool|null)[]|int|string|float|bool|null
Get the value of an unclaimed filter applied to the context via
non-mandatory sync operation arguments
Get the value of an unclaimed filter applied to the context via
non-mandatory sync operation arguments
If $orValue is true and the context has a value for $key , it is
returned if there is no matching filter, otherwise null is returned.
Implemented by
|
#
|
public
|
claimFilter(string $key, bool $orValue = true): (int|string|float|bool|null)[]|int|string|float|bool|null
Claim the value of an unclaimed filter applied via non-mandatory sync
operation arguments, removing it from the context
Claim the value of an unclaimed filter applied via non-mandatory sync
operation arguments, removing it from the context
This method deliberately breaks the context's immutability contract.
If $orValue is true and the context has a value for $key , it is
returned if there is no matching filter, otherwise null is returned.
Implemented by
|
#
|
public
|
getFilters(): array<string, (int|string|float|bool|null)[]|int|string|float|bool|null>
Get unclaimed filters applied to the context via non-mandatory sync
operation arguments
Get unclaimed filters applied to the context via non-mandatory sync
operation arguments
Implemented by
|
#
|
public
|
withOperation(SyncOperation::* $operation, class-string<SyncEntityInterface> $entityType, mixed ...$args): static
Get an instance with the given sync operation and filters derived from
its non-mandatory arguments
Get an instance with the given sync operation and filters derived from
its non-mandatory arguments
An exception is thrown if non-mandatory arguments in $args don't match
one of the following signatures.
- An associative array (
fn(..., array<string,mixed> $filters) )
- Keys are trimmed
- Keys that contain letters or numbers, optionally with inner
whitespace, underscores or hyphens, are converted to snake_case
- A list of identifiers (
fn(..., int ...$ids) or fn(..., string ...$ids) )
- A list of entities (
fn(..., SyncEntityInterface ...$entities) )
- Grouped by snake_case {@see ServiceAwareInterface::getService()}
short names
- Example:
[ 'faculty' => [42, 71], 'faculty_user' => [101] ]
- No arguments (
fn(...) )
In all cases:
- {@see SyncEntityInterface} objects are replaced with their identifiers
- An exception is thrown if any {@see SyncEntityInterface} objects do not
have an identifier ({@see SyncEntityInterface::getId()} returns
null )
or do not have the same provider as the context
- {@see DateTimeInterface} instances are formatted by the provider's date
formatter.
- The result is surfaced via {@see SyncContextInterface::hasFilter()},
{@see SyncContextInterface::getFilter()},
{@see SyncContextInterface::claimFilter()} and
{@see SyncContextInterface::getFilters()}.
{@see SyncContextInterface::claimFilter()} should generally be used to
prevent sync operation failures caused by unclaimed filters.
Parameters
...$args |
Sync operation arguments, not including the
{@see SyncContextInterface} argument.
|
Throws
Implemented by
|
#
|
public
|
getDeferralPolicy(): DeferralPolicy::*
Get the deferral policy applied to the context
Get the deferral policy applied to the context
Implemented by
|
#
|
public
|
withDeferralPolicy(DeferralPolicy::* $policy): static
Get an instance with the given deferral policy
Get an instance with the given deferral policy
Implemented by
|
#
|
public
|
getHydrationPolicy(class-string<SyncEntityInterface>|null $entityType): HydrationPolicy::*
Get the hydration policy applied to the context, optionally scoped by
sync entity type
Get the hydration policy applied to the context, optionally scoped by
sync entity type
Implemented by
|
#
|
public
|
withHydrationPolicy(
HydrationPolicy::* $policy,
class-string<SyncEntityInterface>|null $entityType = null,
array<int<1, max>>|int<1, max>|null $depth = null,
): static
Get an instance with the given hydration policy, optionally scoped by
sync entity type and/or depth
Get an instance with the given hydration policy, optionally scoped by
sync entity type and/or depth
Parameters
$entityType |
Limit the scope
of the change to an entity type.
|
$depth |
Limit the scope of the
change to entities at a given $depth from the current context.
|
Implemented by
|
#
|
public
|
getOffline(): bool|null
Get the offline mode applied to the context
Get the offline mode applied to the context
Returns
-
null (default): entities are returned from the
local entity store if possible, otherwise they are retrieved from the
provider.
-
true : entities are returned from the local entity store without
falling back to retrieval from the provider.
-
false : entities are retrieved from the provider without consulting
the local entity store.
Implemented by
|
#
|
public
|
withOffline(bool|null $offline): static
Get an instance with the given offline mode
Get an instance with the given offline mode
Parameters
$offline |
-
null (default): return entities from the
local entity store if possible, otherwise retrieve them from the
provider.
-
true : return entities from the local entity store without falling
back to retrieval from the provider.
-
false : retrieve entities from the provider without consulting the
local entity store.
|
Implemented by
|
#
|