CollectionInterface
interface CollectionInterface implements NestedCollectionInterface (View source)
Constants
UNNAMEDTASK |
Unnamed tasks are assigned an arbitrary numeric index
in the task list. Any numeric value may be used, but the
UNNAMEDTASK constant is recommended for clarity. |
Methods
Add a task or a list of tasks to our task collection. Each task will run via its 'run()' method once (and if) all of the tasks added before it complete successfully. If the task also implements RollbackInterface, then it will be rolled back via its 'rollback()' method ONLY if its 'run()' method completes successfully, and some task added after it fails.
Add arbitrary code to execute as a task.
Add arbitrary code that will be called once for every item in the provided array or iterable object. If the function result of the provided callback is a TaskInterface or Collection, then it will be executed.
Add a rollback task to our task collection. A rollback task will execute ONLY if all of the tasks added before it complete successfully, AND some task added after it fails.
Add arbitrary code to execute as a rollback.
Add a completion task to our task collection. A completion task will execute EITHER after all tasks succeed, OR immediatley after any task fails. Completion tasks never cause errors to be returned from Collection::run(), even if they fail.
Add arbitrary code to execute as a completion.
Add a task before an existing named task.
Add a task after an existing named task.
Print a progress message after Collection::run() has executed all of the tasks that were added prior to the point when this method was called. If one of the previous tasks fail, then this message will not be printed.
Details
$this
setParentCollection(NestedCollectionInterface $parentCollection)
No description
$this
add(TaskInterface $task, int|string $name = self::UNNAMEDTASK)
Add a task or a list of tasks to our task collection. Each task will run via its 'run()' method once (and if) all of the tasks added before it complete successfully. If the task also implements RollbackInterface, then it will be rolled back via its 'rollback()' method ONLY if its 'run()' method completes successfully, and some task added after it fails.
$this
addCode(callable $code, int|string $name = self::UNNAMEDTASK)
Add arbitrary code to execute as a task.
$this
addIterable(CollectionInterface|array $iterable, callable $code)
Add arbitrary code that will be called once for every item in the provided array or iterable object. If the function result of the provided callback is a TaskInterface or Collection, then it will be executed.
$this
rollback(TaskInterface $rollbackTask)
Add a rollback task to our task collection. A rollback task will execute ONLY if all of the tasks added before it complete successfully, AND some task added after it fails.
$this
rollbackCode(callable $rollbackTask)
Add arbitrary code to execute as a rollback.
$this
completion(TaskInterface $completionTask)
Add a completion task to our task collection. A completion task will execute EITHER after all tasks succeed, OR immediatley after any task fails. Completion tasks never cause errors to be returned from Collection::run(), even if they fail.
$this
completionCode(callable $completionTask)
Add arbitrary code to execute as a completion.
$this
before(string $name, callable|TaskInterface $task, int|string $nameOfTaskToAdd = self::UNNAMEDTASK)
Add a task before an existing named task.
$this
after(string $name, callable|TaskInterface $task, int|string $nameOfTaskToAdd = self::UNNAMEDTASK)
Add a task after an existing named task.
$this
progressMessage(string $text, array $context = [], LogLevel|string $level = LogLevel::NOTICE)
Print a progress message after Collection::run() has executed all of the tasks that were added prior to the point when this method was called. If one of the previous tasks fail, then this message will not be printed.