Beispiel #1
0
 /**
  * Run a task
  *
  * @param Task $task The task
  *
  * @internal Use addTask unless you know what you're doing
  *
  * @return mixed|null The task return value or null when if failed or dry run
  */
 protected function runTask(Task $task)
 {
     if ($if = $task->get('if')) {
         if (is_bool($if)) {
             $shouldRun = $if;
         } elseif (is_string($if)) {
             $shouldRun = (bool) $task->expand('{' . $if . ' ? 1 : 0}');
         } else {
             $shouldRun = call_user_func_array($if, array($task, $this->console));
             if (!is_bool($shouldRun)) {
                 throw new Exception('Callback must return TRUE or FALSE');
             }
         }
     } else {
         $shouldRun = true;
     }
     if ($shouldRun) {
         $return = $task->run();
         $toVar = $task->get('toVar', null);
         if ($toVar) {
             $task->getParent()->set($toVar, $return);
         }
         return $return;
     }
     return null;
 }