/** * Create a TaskWrapper. * * Temporary tasks are always wrapped in a TaskWrapper, as are * any tasks that are added to a collection. If a temporary task * is added to a collection, then it is first unwrapped from its * TaskWrapper (via its getTask method), and then added to a * new TaskWrapper for the collection it is added to. * * In this way, when the TaskWrapper is finally executed, the * task's rollback and completion handlers will be registered on * whichever collection it was registered on. */ public function __construct(Collection $collection, TaskInterface $task, TaskInterface $rollbackTask = null) { $this->collection = $collection; $this->task = $task instanceof self ? $task->getTask() : $task; $this->rollbackTask = $rollbackTask; }