class StaticExportPathCommand in Tome 8
Contains the tome:static-export-path command.
@internal
Hierarchy
- class \Drupal\tome_base\CommandBase extends \Symfony\Component\Console\Command\Command uses ExecutableFinderTrait, ProcessTrait
- class \Drupal\tome_static\Commands\StaticCommand uses StringTranslationTrait, StaticUITrait
- class \Drupal\tome_static\Commands\StaticExportPathCommand
 
 
 - class \Drupal\tome_static\Commands\StaticCommand uses StringTranslationTrait, StaticUITrait
 
Expanded class hierarchy of StaticExportPathCommand
1 string reference to 'StaticExportPathCommand'
- tome_static.services.yml in modules/
tome_static/ tome_static.services.yml  - modules/tome_static/tome_static.services.yml
 
1 service uses StaticExportPathCommand
File
- modules/
tome_static/ src/ Commands/ StaticExportPathCommand.php, line 18  
Namespace
Drupal\tome_static\CommandsView source
class StaticExportPathCommand extends StaticCommand {
  /**
   * The default number of retry per failed process.
   */
  const RETRY_COUNT = 1;
  /**
   * The request preparer.
   *
   * @var \Drupal\tome_static\RequestPreparer
   */
  protected $requestPreparer;
  /**
   * Constructs a StaticCommand instance.
   *
   * @param \Drupal\tome_static\StaticGeneratorInterface $static
   *   The static service.
   * @param \Drupal\Core\State\StateInterface $state
   *   The state system.
   * @param \Drupal\tome_static\RequestPreparer $request_preparer
   *   The request preparer.
   */
  public function __construct(StaticGeneratorInterface $static, StateInterface $state, RequestPreparer $request_preparer) {
    parent::__construct($static, $state);
    $this->requestPreparer = $request_preparer;
  }
  /**
   * {@inheritdoc}
   */
  protected function configure() {
    $this
      ->setName('tome:static-export-path')
      ->setDescription('Exports static HTML for a specific path.')
      ->addArgument('chunk', InputArgument::REQUIRED, 'A comma separated list of paths.')
      ->addOption('process-count', NULL, InputOption::VALUE_OPTIONAL, 'Limits the number of processes to run concurrently.', static::PROCESS_COUNT)
      ->addOption('path-count', NULL, InputOption::VALUE_OPTIONAL, 'The number of paths to export per process.', static::PATH_COUNT)
      ->addOption('return-json', NULL, InputOption::VALUE_NONE, 'Whether or not paths that need invoking should be returned as JSON.')
      ->addOption('retry-count', NULL, InputOption::VALUE_OPTIONAL, 'The number of retry per failed process', static::RETRY_COUNT);
  }
  /**
   * {@inheritdoc}
   */
  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']);
    }
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            CommandBase:: | 
                  protected | property | The current executable path. | |
| 
            CommandBase:: | 
                  protected | property | The IO decorator. | |
| 
            CommandBase:: | 
                  protected | function | ||
| 
            CommandBase:: | 
                  protected | function | 
            Returns the IO decorator, for reporting errors. Overrides ProcessTrait:: | 
                  |
| 
            ExecutableFinderTrait:: | 
                  protected | function | Finds an executable string for the current process. | |
| 
            ProcessTrait:: | 
                  protected | function | Displays errors using the IO component. | |
| 
            ProcessTrait:: | 
                  protected | function | Runs a single command and outputs errors if encountered. | |
| 
            ProcessTrait:: | 
                  protected | function | Runs commands with concurrency. | |
| 
            StaticCommand:: | 
                  protected | property | The state system. | |
| 
            StaticCommand:: | 
                  protected | property | The static service. | |
| 
            StaticCommand:: | 
                  protected | function | Exports the given paths to the static directory. | |
| 
            StaticCommand:: | 
                  constant | The default number of paths to export per process. | ||
| 
            StaticCommand:: | 
                  constant | The default number of processes to invoke. | ||
| 
            StaticExportPathCommand:: | 
                  protected | property | The request preparer. | |
| 
            StaticExportPathCommand:: | 
                  protected | function | 
            Overrides StaticCommand:: | 
                  |
| 
            StaticExportPathCommand:: | 
                  protected | function | 
            Overrides StaticCommand:: | 
                  |
| 
            StaticExportPathCommand:: | 
                  constant | 
            The default number of retry per failed process. Overrides StaticCommand:: | 
                  ||
| 
            StaticExportPathCommand:: | 
                  public | function | 
            Constructs a StaticCommand instance. Overrides StaticCommand:: | 
                  |
| 
            StaticUITrait:: | 
                  protected | function | Formats an exception caught when requesting a path. | |
| 
            StaticUITrait:: | 
                  protected | function | Collects warnings to help users correct issues in rendered HTML. | |
| 
            StaticUITrait:: | 
                  abstract protected | function | Translates a string to the current language or to a given language. | |
| 
            StringTranslationTrait:: | 
                  protected | property | The string translation service. | 1 | 
| 
            StringTranslationTrait:: | 
                  protected | function | Formats a string containing a count of items. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Returns the number of plurals supported by a given language. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Gets the string translation service. | |
| 
            StringTranslationTrait:: | 
                  public | function | Sets the string translation service to use. | 2 |