class InstallCommand in CKEditor Media Embed Plugin 8
Same name in this branch
- 8 src/Command/InstallCommand.php \Drupal\ckeditor_media_embed\Command\InstallCommand
 - 8 src/Command/Drush/InstallCommand.php \Drupal\ckeditor_media_embed\Command\Drush\InstallCommand
 
Class InstallCommand.
Hierarchy
- class \Drupal\ckeditor_media_embed\Command\Drush\InstallCommand implements CKEditorCliCommandInterface
 
Expanded class hierarchy of InstallCommand
1 string reference to 'InstallCommand'
1 service uses InstallCommand
File
- src/
Command/ Drush/ InstallCommand.php, line 15  
Namespace
Drupal\ckeditor_media_embed\Command\DrushView source
class InstallCommand implements CKEditorCliCommandInterface {
  /**
   * The CKEditor Media Embed CLI Commands service.
   *
   * @var \Drupal\ckeditor_media_embed\CLICommands
   */
  protected $cliCommands;
  /**
   * The messages displayed to the user at various steps of the installation.
   *
   * @var string[]
   */
  protected $messages;
  /**
   * Constructs command object.
   *
   * @param \Drupal\ckeditor_media_embed\Command\CliCommandWrapper $cli_commands
   *   The CKEditor Media Embed CLI Commands service.
   */
  public function __construct(CliCommandWrapper $cli_commands) {
    $this->cliCommands = $cli_commands;
    $this
      ->setMessages();
  }
  /**
   * Executes the command.
   *
   * @param \Symfony\Component\Console\Input\InputInterface $input
   *   An InputInterface instance.
   * @param \Symfony\Component\Console\Output\OutputInterface $output
   *   An OutputInterface instance.
   * @param \Drush\Style\DrushStyle $io
   *   The Drush i/o object.
   */
  public function execute(InputInterface $input, OutputInterface $output, DrushStyle $io) {
    $this->input = $input;
    $this->output = $output;
    $this->io = $io;
    $overwrite = $this->cliCommands
      ->askToOverwritePluginFiles($this);
    if ($overwrite) {
      $this->cliCommands
        ->overwritePluginFiles($this, $overwrite);
    }
  }
  /**
   * Set messages to display to the user at various steps of the installation.
   *
   * @return $this
   */
  protected function setMessages() {
    $messages_file = \Drupal::service('module_handler')
      ->getModule('ckeditor_media_embed')
      ->getPath() . '/console/translations/en/ckeditor_media_embed.install.yml';
    $messages = Yaml::decode(file_get_contents($messages_file))['messages'];
    $this->messages = array_map(function ($message) {
      return dt($message);
    }, $messages);
    return $this;
  }
  /**
   * {@inheritdoc}
   */
  public function getInput() {
    return $this->input;
  }
  /**
   * {@inheritdoc}
   */
  public function getIo() {
    return $this->io;
  }
  /**
   * {@inheritdoc}
   */
  public function getMessage($message_key) {
    return $this->messages[$message_key];
  }
  /**
   * {@inheritdoc}
   */
  public function confirmation($question, $default = FALSE) {
    return $this->io
      ->confirm($question, $default);
  }
  /**
   * {@inheritdoc}
   */
  public function comment($text) {
    $this->io
      ->text(sprintf('<comment>%s</comment>', $text));
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            InstallCommand:: | 
                  protected | property | The CKEditor Media Embed CLI Commands service. | |
| 
            InstallCommand:: | 
                  protected | property | The messages displayed to the user at various steps of the installation. | |
| 
            InstallCommand:: | 
                  public | function | 
            Output message in comment style. Overrides CKEditorCliCommandInterface:: | 
                  |
| 
            InstallCommand:: | 
                  public | function | 
            Present confirmation question to user. Overrides CKEditorCliCommandInterface:: | 
                  |
| 
            InstallCommand:: | 
                  public | function | Executes the command. | |
| 
            InstallCommand:: | 
                  public | function | 
            Retrieve the command input service. Overrides CKEditorCliCommandInterface:: | 
                  |
| 
            InstallCommand:: | 
                  public | function | 
            Retrieve the i/o style. Overrides CKEditorCliCommandInterface:: | 
                  |
| 
            InstallCommand:: | 
                  public | function | 
            Retrieve message text. Overrides CKEditorCliCommandInterface:: | 
                  |
| 
            InstallCommand:: | 
                  protected | function | Set messages to display to the user at various steps of the installation. | |
| 
            InstallCommand:: | 
                  public | function | Constructs command object. |