/** * Register a completion task to run once all other tasks finish. * Completion tasks run whether or not a rollback operation was * triggered. They do not trigger rollbacks if they fail. * * The typical use-case for a completion function is to clean up * temporary objects (e.g. temporary folders). The preferred * way to do that, though, is to use Temporary::wrap(). * * On failures, completion tasks will run after all rollback tasks. * If one task collection is nested inside another task collection, * then the nested collection's completion tasks will run as soon as * the nested task completes; they are not deferred to the end of * the containing collection's execution. * * @param TaskInterface $completionTask * The completion task to run at the end of all other operations. */ public function registerCompletion(TaskInterface $completionTask) { if ($this->parentCollection) { return $this->parentCollection->registerCompletion($completionTask); } if ($completionTask) { // Completion tasks always try as hard as they can, and never report failures. $completionTask = $this->ignoreErrorsTaskWrapper($completionTask); $this->completionStack[] = $completionTask; } }
/** * Return the collection of tasks associated with this builder. * * @return CollectionInterface */ public function getCollection() { if (!isset($this->collection)) { $this->collection = new Collection(); $this->collection->inflect($this); $this->collection->setProgressBarAutoDisplayInterval($this->getConfig()->get(Config::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL)); if (isset($this->currentTask)) { $this->collection->add($this->currentTask); } } return $this->collection; }