Documentation

ScopedContextInterface extends WorkflowContextInterface

Handles scope creation.

Table of Contents

Methods

allHandlersFinished()  : bool
Whether update and signal handlers have finished executing.
async()  : CancellationScopeInterface
The method calls an asynchronous task and returns a promise.
asyncDetached()  : CancellationScopeInterface
Cancellation scope which does not react to parent cancel and completes in background.
await()  : PromiseInterface
Moves to the next step if the expression evaluates to `true`.
awaitWithTimeout()  : PromiseInterface<string|int, bool>
Checks if any conditions were met or the timeout was reached.
continueAsNew()  : PromiseInterface
Completes the current workflow execution atomically and starts a new execution with the same Workflow Id.
executeActivity()  : PromiseInterface<string|int, mixed>
Calls an activity by its name and gets the result of its execution.
executeChildWorkflow()  : PromiseInterface
Calls an external workflow without stopping the current one.
getInfo()  : WorkflowInfo
Returns information about current workflow execution.
getInput()  : ValuesInterface
Returns workflow execution input arguments.
getLastCompletionResult()  : mixed
Get value of last completion result, if any.
getStackTrace()  : string
Returns a complete trace of the last calls (for debugging).
getVersion()  : PromiseInterface
Updates the behavior of an existing workflow to resolve inconsistency errors during replay.
isReplaying()  : bool
newActivityStub()  : T
The method returns a proxy over the class containing the activity, which allows you to conveniently and beautifully call all methods within the passed class.
newChildWorkflowStub()  : T
Creates a proxy for a workflow class to execute as a child workflow.
newContinueAsNewStub()  : T
Creates client stub that can be used to continue this workflow as new.
newExternalWorkflowStub()  : T
Creates client stub that can be used to communicate to an existing workflow execution.
newUntypedActivityStub()  : ActivityStubInterface
The method creates and returns a proxy class with the specified settings that allows to call an activities with the passed options.
newUntypedChildWorkflowStub()  : ChildWorkflowStubInterface
Creates a proxy for a workflow by name to execute as a child workflow.
newUntypedExternalWorkflowStub()  : ExternalWorkflowStubInterface
Creates untyped client stub that can be used to signal or cancel a child workflow.
now()  : DateTimeInterface
registerDynamicQuery()  : $this
Registers a dynamic Query handler.
registerDynamicSignal()  : $this
Registers a dynamic Signal handler.
registerDynamicUpdate()  : $this
Registers a dynamic Update handler.
registerQuery()  : $this
A method that allows you to dynamically register additional query handler in a workflow during the execution of a workflow.
registerSignal()  : $this
Registers a query with an additional signal handler.
registerUpdate()  : static
Registers an Update method with an optional validator.
sideEffect()  : PromiseInterface<string|int, TReturn>
Isolates non-pure data to ensure consistent results during workflow replays.
timer()  : PromiseInterface
Stops workflow execution work for a specified period.
upsertMemo()  : void
Updates this Workflow's Memos by merging the provided memo with existing Memos.
upsertSearchAttributes()  : void
Upsert search attributes
upsertTypedSearchAttributes()  : void
Upsert typed Search Attributes
uuid()  : PromiseInterface<string|int, UuidInterface>
Generate a UUID.
uuid4()  : PromiseInterface<string|int, UuidInterface>
Generate a UUID version 4 (random).
uuid7()  : PromiseInterface<string|int, UuidInterface>
Generate a UUID version 7 (Unix Epoch time).

Methods

allHandlersFinished()

Whether update and signal handlers have finished executing.

public allHandlersFinished() : bool

Consider waiting on this condition before workflow return or continue-as-new, to prevent interruption of in-progress handlers by workflow exit:

 yield Workflow.await(static fn() => Workflow::allHandlersFinished());
Return values
bool

True if all handlers have finished executing.

await()

Moves to the next step if the expression evaluates to `true`.

public await(callable|Mutex|PromiseInterface ...$conditions) : PromiseInterface
Parameters
$conditions : callable|Mutex|PromiseInterface
Tags
see
Workflow::await()
Return values
PromiseInterface

awaitWithTimeout()

Checks if any conditions were met or the timeout was reached.

public awaitWithTimeout(DateIntervalValue $interval, callable|Mutex|PromiseInterface ...$conditions) : PromiseInterface<string|int, bool>

Returns true if any of conditions were fired and false if timeout was reached.

Parameters
$interval : DateIntervalValue
$conditions : callable|Mutex|PromiseInterface
Tags
see
Workflow::awaitWithTimeout()
Return values
PromiseInterface<string|int, bool>

continueAsNew()

Completes the current workflow execution atomically and starts a new execution with the same Workflow Id.

public continueAsNew(string $type[, array<string|int, mixed> $args = [] ][, ContinueAsNewOptions|null $options = null ]) : PromiseInterface
Parameters
$type : string
$args : array<string|int, mixed> = []
$options : ContinueAsNewOptions|null = null
Tags
see
Workflow::continueAsNew()
Return values
PromiseInterface

executeActivity()

Calls an activity by its name and gets the result of its execution.

public executeActivity(string $type[, array<string|int, mixed> $args = [] ][, ActivityOptions|null $options = null ][, Type|string|ReflectionClass|ReflectionType|null $returnType = null ]) : PromiseInterface<string|int, mixed>
Parameters
$type : string
$args : array<string|int, mixed> = []
$options : ActivityOptions|null = null
$returnType : Type|string|ReflectionClass|ReflectionType|null = null
Tags
see
Workflow::executeActivity()
Return values
PromiseInterface<string|int, mixed>

executeChildWorkflow()

Calls an external workflow without stopping the current one.

public executeChildWorkflow(string $type[, array<string|int, mixed> $args = [] ][, ChildWorkflowOptions|null $options = null ][, Type|string|ReflectionType|ReflectionClass|null $returnType = null ]) : PromiseInterface
Parameters
$type : string
$args : array<string|int, mixed> = []
$options : ChildWorkflowOptions|null = null
$returnType : Type|string|ReflectionType|ReflectionClass|null = null
Tags
see
Workflow::executeChildWorkflow()
Return values
PromiseInterface

getVersion()

Updates the behavior of an existing workflow to resolve inconsistency errors during replay.

public getVersion(string $changeId, int $minSupported, int $maxSupported) : PromiseInterface
Parameters
$changeId : string
$minSupported : int
$maxSupported : int
Tags
see
Workflow::getVersion()
Return values
PromiseInterface

registerDynamicQuery()

Registers a dynamic Query handler.

public registerDynamicQuery(callable(non-empty-string, ValuesInterface): mixed $handler) : $this
Parameters
$handler : callable(non-empty-string, ValuesInterface): mixed

The handler to call when a Query is received. The first parameter is the Query name, the second is Query arguments.

Tags
since

SDK 2.14.0

Return values
$this

registerDynamicSignal()

Registers a dynamic Signal handler.

public registerDynamicSignal(callable(non-empty-string, ValuesInterface): mixed $handler) : $this
Parameters
$handler : callable(non-empty-string, ValuesInterface): mixed

The handler to call when a Signal is received. The first parameter is the Signal name, the second is Signal arguments.

Tags
since

SDK 2.14.0

Return values
$this

registerDynamicUpdate()

Registers a dynamic Update handler.

public registerDynamicUpdate(callable(non-empty-string, ValuesInterface): mixed $handler[, null|callable(non-empty-string, ValuesInterface): mixed $validator = null ]) : $this
Parameters
$handler : callable(non-empty-string, ValuesInterface): mixed

The Update handler The first parameter is the Update name, the second is Update arguments.

$validator : null|callable(non-empty-string, ValuesInterface): mixed = null

The Update validator The first parameter is the Update name, the second is Update arguments. It should throw an exception if the validation fails.

Tags
since

SDK 2.14.0

Return values
$this

registerQuery()

A method that allows you to dynamically register additional query handler in a workflow during the execution of a workflow.

public registerQuery(non-empty-string $queryType, callable $handler) : $this
Parameters
$queryType : non-empty-string
$handler : callable
Tags
see
Workflow::registerQuery()
Return values
$this

registerSignal()

Registers a query with an additional signal handler.

public registerSignal(non-empty-string $queryType, callable $handler) : $this
Parameters
$queryType : non-empty-string
$handler : callable
Tags
see
Workflow::registerSignal()
Return values
$this

registerUpdate()

Registers an Update method with an optional validator.

public registerUpdate(non-empty-string $name, callable $handler, callable|null $validator) : static
Parameters
$name : non-empty-string
$handler : callable
$validator : callable|null
Tags
see
Workflow::registerUpdate()
Return values
static

sideEffect()

Isolates non-pure data to ensure consistent results during workflow replays.

public sideEffect(callable(): TReturn $context) : PromiseInterface<string|int, TReturn>
Parameters
$context : callable(): TReturn
Tags
see
Workflow::sideEffect()
template

TReturn

Return values
PromiseInterface<string|int, TReturn>

timer()

Stops workflow execution work for a specified period.

public timer(DateIntervalValue $interval) : PromiseInterface
Parameters
$interval : DateIntervalValue
Tags
see
Workflow::timer()
see
DateInterval
Return values
PromiseInterface

upsertMemo()

Updates this Workflow's Memos by merging the provided memo with existing Memos.

public upsertMemo(array<non-empty-string, mixed> $values) : void

New Memo is merged by replacing properties of the same name at the first level only. Setting a property to null clears that key from the Memo.

For example:

 Workflow::upsertMemo([
     'key1' => 'value',
     'key3' => ['subkey1' => 'value']
     'key4' => 'value',
 });

 Workflow::upsertMemo([
     'key2' => 'value',
     'key3' => ['subkey2' => 'value']
     'key4' => null,
 ]);

would result in the Workflow having these Memo:

 [
     'key1' => 'value',
     'key2' => 'value',
     'key3' => ['subkey2' => 'value'], // Note this object was completely replaced
     // Note that 'key4' was completely removed
 ]
Parameters
$values : array<non-empty-string, mixed>
Tags
since

SDK 2.13.0

since

RoadRunner 2024.3.3

link
https://docs.temporal.io/glossary#memo

upsertSearchAttributes()

Upsert search attributes

public upsertSearchAttributes(array<non-empty-string, mixed> $searchAttributes) : void
Parameters
$searchAttributes : array<non-empty-string, mixed>

upsertTypedSearchAttributes()

Upsert typed Search Attributes

public upsertTypedSearchAttributes(SearchAttributeUpdate ...$updates) : void
 Workflow::upsertTypedSearchAttributes(
     SearchAttributeKey::forKeyword('CustomKeyword')->valueSet('CustomValue'),
     SearchAttributeKey::forInt('MyCounter')->valueSet(42),
 );
Parameters
$updates : SearchAttributeUpdate
Tags
since

SDK 2.13.0

since

RoadRunner 2024.3.2

link
https://docs.temporal.io/visibility#search-attribute

uuid4()

Generate a UUID version 4 (random).

public uuid4() : PromiseInterface<string|int, UuidInterface>
Tags
see
Workflow::uuid4()
Return values
PromiseInterface<string|int, UuidInterface>

uuid7()

Generate a UUID version 7 (Unix Epoch time).

public uuid7([DateTimeInterface|null $dateTime = null ]) : PromiseInterface<string|int, UuidInterface>
Parameters
$dateTime : DateTimeInterface|null = null

An optional date/time from which to create the version 7 UUID. If not provided, the UUID is generated using the current date/time.

Tags
see
Workflow::uuid7()
Return values
PromiseInterface<string|int, UuidInterface>

        
On this page

Search results