Methods |
public
|
pushEntity($entity, bool $detectRecursion = false)
Add the entity for which the context is being propagated
Add the entity for which the context is being propagated
If $entity implements {@see HasId} and the return value of
{@see HasId::getId()} is not null , it is applied to the context as a
value with name <entity_basename>_id .
Overrides
Implements
|
#
|
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()
Implements
|
#
|
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
Implements
|
#
|
public
|
getOperation(): ?int
Get the sync operation applied to the context
Get the sync operation applied to the context
Implements
|
#
|
public
|
hasFilter(?string $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.
|
Implements
|
#
|
public
|
getFilter(string $key, bool $orValue = true)
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.
Implements
|
#
|
public
|
claimFilter(string $key, bool $orValue = true)
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.
Implements
|
#
|
public
|
getFilters(): array
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
Implements
|
#
|
public
|
withOperation(int $operation, string $entityType, ...$args)
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.
|
Implements
|
#
|
public
|
getDeferralPolicy(): int
Get the deferral policy applied to the context
Get the deferral policy applied to the context
Implements
|
#
|
public
|
withDeferralPolicy(int $policy)
Get an instance with the given deferral policy
Get an instance with the given deferral policy
Implements
|
#
|
public
|
getHydrationPolicy(?string $entityType): int
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
Implements
|
#
|
public
|
withHydrationPolicy(int&HydrationPolicy::* $policy, ?string $entityType = null, $depth = null)
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.
|
Implements
|
#
|
public
|
getOffline(): ?bool
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.
Implements
|
#
|
public
|
withOffline(?bool $offline)
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.
|
Implements
|
#
|