InstallCommand.php in CKEditor Media Embed Plugin 8
File
src/Command/InstallCommand.php
View source
<?php
namespace Drupal\ckeditor_media_embed\Command;
use Drupal\Console\Annotations\DrupalCommand;
use Drupal\Console\Core\Command\Command;
use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
use Drupal\Console\Core\Style\DrupalStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
class InstallCommand extends Command implements CKEditorCliCommandInterface {
use ContainerAwareCommandTrait;
protected $cliCommands;
public function __construct(CliCommandWrapper $cliCommands) {
parent::__construct();
$this->cliCommands = $cliCommands;
}
protected function configure() {
$this
->setName('ckeditor_media_embed:install')
->setDescription($this
->trans('commands.ckeditor_media_embed.install.description'));
}
protected function execute(InputInterface $input, OutputInterface $output) {
$this->input = $input;
$this->output = $output;
$this->io = new DrupalStyle($input, $output);
$overwrite = $this->cliCommands
->askToOverwritePluginFiles($this);
if ($overwrite) {
$this->cliCommands
->overwritePluginFiles($this, $overwrite);
}
}
public function getInput() {
return $this->input;
}
public function getIo() {
return $this->io;
}
public function getMessage($message_key) {
return $this
->trans("commands.ckeditor_media_embed.install.messages.{$message_key}");
}
public function confirmation($question, $default = FALSE) {
$helper = $this
->getHelper('question');
$confirmation_question = new ConfirmationQuestion($question, $default);
return $helper
->ask($this->input, $this->output, $confirmation_question);
}
public function comment($text) {
$this->io
->comment($text);
}
}