Download the PHP package leadvertex/plugin-component-process without Composer
On this page you can find all versions of the php package leadvertex/plugin-component-process. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download leadvertex/plugin-component-process
More information about leadvertex/plugin-component-process
Files in leadvertex/plugin-component-process
Package plugin-component-process
Short Description LeadVertex plugin process handler component
License proprietary
Informations about the package plugin-component-process
LeadVertex process plugin component
\Leadvertex\Plugin\Components\Process
- component, which designed to store and provide information
about the current state of the process based on the base DB model
from DB plugin component
and accepts process id into itself.
Installation
Usage
For example, you can create new process like this:
Note, that you need to use save() method to save actual information to DB.
Initialize method
Method initialize()
is intended to indicate the number of entities being processed.\
It accepts a number of entities, to be handled. The number may be null for cases where you cannot determine
its exact value.\
Note, that you must initialize process before you can use its handle()
, skip()
and finish()
methods.\
You can check if the process has already been initialized with isInitialized()
method.
Handle method
Method handle()
is intended to increase the number of successfully processed entities.\
You can get current number of handled entities with getHandledCount()
method.
Skip method
Method skip()
is intended to skip processing of current entities. You can use it in cases, when your entity become
inaccessible or was deleted during processing.\
You can get current number of skipped entities with getSkippedCount()
method.
AddError method
Method addError()
is intended to be used when handle of current entity fails.\
It accepts an instance of \Leadvertex\Plugin\Components\Process\Components\Error
into itself. You can use it like this:
You can get list of 20 last errors with getLastErrors()
method.
Terminate method
Method terminate()
is intended to stop execution of process due to fatal error.\
It accepts an instance of \Leadvertex\Plugin\Components\Process\Components\Error
into itself,
adds an error in similar to addError()
method way, marks handle of all remaining entities as failed,
sets result of process execution as false
and sets updatedAt
property of model as the current DateTime.\
You can get result of the process execution with getResult()
method.\
You can use this method like this:
Finish method
Method finish()
is intended to be used when your process finished all its work.\
It accepts a result into itself which can be one of the 3 following types:
bool
- is used when you need to return final status of your process execution.int
- is used when you need to return number of handled entities.string
- is used when you need to return URI in result.
Also it sets result of process execution as the accepted value
and sets updatedAt
property of model as the current DateTime.
JsonSerializable
Process implements a built-in jsonSerializable
interface, which means you can get process info as a serialized json by simply using
json_encode to process instance.
For example, you can use it like this: