예제 #1
0
 /**
  * Execute a task and consider configured before / after "hooks"
  *
  * Will also execute tasks that are registered to run before or after this task.
  *
  * @param string $task
  * @param \TYPO3\Surf\Domain\Model\Node $node
  * @param \TYPO3\Surf\Domain\Model\Application $application
  * @param \TYPO3\Surf\Domain\Model\Deployment $deployment
  * @param string $stage
  * @param array $callstack
  * @return void
  * @throws \TYPO3\Surf\Exception\TaskExecutionException
  */
 protected function executeTask($task, Node $node, Application $application, Deployment $deployment, $stage, array &$callstack = array())
 {
     foreach (array('_', $application->getName()) as $applicationName) {
         if (isset($this->tasks['before'][$applicationName][$task])) {
             foreach ($this->tasks['before'][$applicationName][$task] as $beforeTask) {
                 $deployment->getLogger()->debug('Task "' . $beforeTask . '" before "' . $task);
                 $this->executeTask($beforeTask, $node, $application, $deployment, $stage, $callstack);
             }
         }
     }
     if (isset($callstack[$task])) {
         throw new \TYPO3\Surf\Exception\TaskExecutionException('Cycle for task "' . $task . '" detected, aborting.', 1335976544);
     }
     if (isset($this->tasks['defined'][$task])) {
         $this->taskManager->execute($this->tasks['defined'][$task]['task'], $node, $application, $deployment, $stage, $this->tasks['defined'][$task]['options'], $task);
     } else {
         $this->taskManager->execute($task, $node, $application, $deployment, $stage);
     }
     $callstack[$task] = true;
     foreach (array('_', $application->getName()) as $applicationName) {
         $label = $applicationName === '_' ? 'for all' : 'for application ' . $applicationName;
         if (isset($this->tasks['after'][$applicationName][$task])) {
             foreach ($this->tasks['after'][$applicationName][$task] as $beforeTask) {
                 $deployment->getLogger()->debug('Task "' . $beforeTask . '" after "' . $task . '" ' . $label);
                 $this->executeTask($beforeTask, $node, $application, $deployment, $stage, $callstack);
             }
         }
     }
 }
예제 #2
0
 /**
  * @test
  */
 public function executePassePrefixedDefinedTaskOptionsToDefinedTask()
 {
     $globalOptions = array('MyVendor\\MyPackage\\DefinedTask\\TaskGroup\\MyTask[taskOption]' => 'Foo');
     $this->deployment->setOptions($globalOptions);
     $this->task->expects($this->atLeastOnce())->method('execute')->with($this->anything(), $this->anything(), $this->anything(), $this->arrayHasKey('taskOption'));
     $localOptions = array();
     $this->taskManager->execute('MyVendor\\MyPackage\\Task\\TaskGroup\\MyTask', $this->node, $this->application, $this->deployment, 'test', $localOptions, 'MyVendor\\MyPackage\\DefinedTask\\TaskGroup\\MyTask');
 }