/**
  * @param BatchManager           $batches
  * @param ServerRequestInterface $request
  * @param string                 $task
  *
  * @return View
  */
 public function index(BatchManager $batches, ServerRequestInterface $request, $task = 'custom')
 {
     // Interactive mode
     $query = $request->getQueryParams();
     if (array_key_exists('interactive', $query)) {
         $this->configuration['tasks'] = $query['interactive'];
     }
     $task = $this->getTask($task);
     $sync = array_get($query, 'sync');
     $method = $sync ? 'runTask' : 'getCommandsFrom';
     $commands = $this->runner->{$method}($task);
     // Store commands for retrieval
     $hash = $batches->set($commands);
     return $this->views->render('index', ['tasks' => $commands, 'hash' => $hash, 'url' => $this->configuration->get('url')]);
 }
 /**
  * @param Command $command
  *
  * @return Command
  */
 public function runCommand(Command $command)
 {
     // Build process
     $process = new Process($command->sanitized, $this->configuration->get('paths.app'));
     // Run process
     $output = '';
     if (!$this->pretend) {
         $process->run(function ($type, $buffer) use(&$output) {
             $output .= $buffer;
         });
     }
     // Wait for process
     while ($process->isRunning()) {
         // ...
     }
     // Update command
     $command->output = trim($output, PHP_EOL) . PHP_EOL;
     $command->status = $process->getExitCode() === 0 || $this->pretend;
     $command->done = true;
     return $command;
 }
 /**
  * @return MiddlewareInterface[]
  */
 protected function getMiddlewares()
 {
     return [new WhitelistMiddleware($this->configuration->get('allowed_ips')), LeagueRouteMiddleware::class];
 }
Пример #4
0
 /**
  * @param Configuration $configuration
  */
 public function __construct(Configuration $configuration)
 {
     $this->folder = $configuration->get('paths.cache') . '/batches';
 }