view vendor/chi-teck/drupal-code-generator/src/Command/Other/HtmlPage.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
line wrap: on
line source
<?php

namespace DrupalCodeGenerator\Command\Other;

use DrupalCodeGenerator\Command\BaseGenerator;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

/**
 * Implements other:html-page command.
 */
class HtmlPage extends BaseGenerator {

  protected $name = 'other:html-page';
  protected $description = 'Generates a simple html page';
  protected $alias = 'html-page';
  protected $label = 'HTML page';
  protected $destination = FALSE;

  /**
   * {@inheritdoc}
   */
  protected function interact(InputInterface $input, OutputInterface $output) {
    $questions['file_name'] = new Question('File name', 'index.html');

    $this->collectVars($input, $output, $questions);

    $this->addFile()
      ->path('{file_name}')
      ->template('other/html.twig');

    $this->addFile()
      ->path('css/main.css')
      ->content("body{\n  background-color: #EEE;\n}\n");

    $this->addFile()
      ->path('js/main.js')
      ->content("console.log('It works!');\n");
  }

}