You are here

protected function StaticPreviewCommand::execute in Tome 8

File

modules/tome_static/src/Commands/StaticPreviewCommand.php, line 52

Class

StaticPreviewCommand
Contains the tome:preview command.

Namespace

Drupal\tome_static\Commands

Code

protected function execute(InputInterface $input, OutputInterface $output) {
  if (!file_exists($this->static
    ->getStaticDirectory())) {
    $this
      ->io()
      ->error('Static directory does not exist. Have you ran the "tome:static" command yet?');
    return 1;
  }
  $options = $input
    ->getOptions();
  $url = '127.0.0.1:' . $options['port'];
  $this
    ->startBrowser('http://' . $url . base_path(), 2);
  $this
    ->runCommand('php -S ' . escapeshellarg($url), $this->static
    ->getStaticDirectory(), NULL);
}