示例#1
0
 /**
  * Before running this task, register its rollback and completion
  * handlers on its collection. The reason this class exists is to
  * defer registration of rollback and completion tasks until 'run()' time.
  *
  * @return \Robo\Result
  */
 public function run()
 {
     if ($this->rollbackTask) {
         $this->collection->registerRollback($this->rollbackTask);
     }
     if ($this->task instanceof RollbackInterface) {
         $this->collection->registerRollback(new CallableTask([$this->task, 'rollback'], $this->task));
     }
     if ($this->task instanceof CompletionInterface) {
         $this->collection->registerCompletion(new CallableTask([$this->task, 'complete'], $this->task));
     }
     return $this->task->run();
 }
示例#2
0
 /**
  * If there is a single task, run it; if there is a collection, run
  * all of its tasks.
  *
  * @return \Robo\Result
  */
 protected function runTasks()
 {
     if (!$this->collection && $this->currentTask) {
         return $this->currentTask->run();
     }
     return $this->getCollection()->run();
 }
示例#3
0
 /**
  * @param \Robo\Result|\Robo\Contract\TaskInterface $result
  * @param \Consolidation\AnnotatedCommand\CommandData $commandData
  *
  * @return null|\Robo\Result
  */
 public function process($result, CommandData $commandData)
 {
     if ($result instanceof TaskInterface) {
         try {
             return $result->run();
         } catch (\Exception $e) {
             return Result::fromException($result, $e);
         }
     }
 }
示例#4
0
文件: Collection.php 项目: jjok/Robo
 /**
  * @param TaskInterface|NestedCollectionInterface|WrappedTaskInterface $task
  *
  * @return \Robo\Result
  */
 protected function runSubtask($task)
 {
     $original = $task instanceof WrappedTaskInterface ? $task->original() : $task;
     $this->setParentCollectionForTask($original, $this->getParentCollection());
     if ($original instanceof InflectionInterface) {
         $original->inflect($this);
     }
     $taskResult = $task->run();
     return $taskResult;
 }
示例#5
0
文件: Base.php 项目: GreenCape/robo
 /**
  * @param TaskInterface $task
  *
  * @return Result
  */
 private function runSilently(TaskInterface $task)
 {
     $this->suppressOutput();
     $result = $task->run();
     $this->restoreOutput();
     return $result;
 }