You are here

protected function StaticExportPathCommand::execute in Tome 8

Overrides StaticCommand::execute

File

modules/tome_static/src/Commands/StaticExportPathCommand.php, line 63

Class

StaticExportPathCommand
Contains the tome:static-export-path command.

Namespace

Drupal\tome_static\Commands

Code

protected function execute(InputInterface $input, OutputInterface $output) {
  $chunk = $input
    ->getArgument('chunk');
  $paths = explode(',', $chunk);
  $invoke_paths = [];
  foreach ($paths as $path) {
    $this->requestPreparer
      ->prepareForRequest();
    try {
      $invoke_paths = array_merge($this->static
        ->requestPath($path), $invoke_paths);
    } catch (\Exception $e) {
      $this->io
        ->getErrorStyle()
        ->error($this
        ->formatPathException($path, $e));
    }
  }
  $options = $input
    ->getOptions();
  if ($options['return-json']) {
    $this->io
      ->write(json_encode($invoke_paths, JSON_PRETTY_PRINT));
  }
  else {
    $this
      ->exportPaths($invoke_paths, $paths, $options['process-count'], $options['path-count'], FALSE, $options['retry-count'], $options['uri']);
  }
}