winter/modules/system/console/WinterDown.php

87 lines
2.1 KiB
PHP
Raw Normal View History

2014-05-14 23:24:20 +10:00
<?php namespace System\Console;
use App;
2014-05-14 23:24:20 +10:00
use Illuminate\Console\Command;
use System\Classes\UpdateManager;
use Symfony\Component\Console\Input\InputOption;
/**
* Console command to tear down the database.
*
* This destroys all database tables that are registered for Winter and all plugins.
*
* @package winter\wn-system-module
* @author Alexey Bobkov, Samuel Georges
*/
class WinterDown extends Command
2014-05-14 23:24:20 +10:00
{
use \Illuminate\Console\ConfirmableTrait;
2014-05-14 23:24:20 +10:00
/**
* The console command name.
*/
protected $name = 'winter:down';
2014-05-14 23:24:20 +10:00
/**
* The console command description.
*/
protected $description = 'Destroys all database tables for Winter and all plugins.';
2014-05-14 23:24:20 +10:00
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
// Register aliases for backwards compatibility with October
$this->setAliases(['october:down']);
}
2014-05-14 23:24:20 +10:00
/**
* Execute the console command.
*/
2017-07-14 16:28:47 +10:00
public function handle()
2014-05-14 23:24:20 +10:00
{
if (App::isProduction() && !$this->option('force')) {
$this->warn('YOUR APPLICATION IS IN PRODUCTION');
2014-10-18 11:58:50 +02:00
}
2014-05-14 23:24:20 +10:00
$this->warn('This will completely delete all database tables in use with your Winter installation.');
$confirmed = false;
$prompt = 'Please type "DELETE" to proceed';
do {
if (strtolower($this->ask($prompt)) === 'delete') {
$confirmed = true;
}
} while ($confirmed === false);
2017-05-20 09:03:58 +10:00
UpdateManager::instance()
->setNotesOutput($this->output)
->uninstall()
;
2014-05-14 23:24:20 +10:00
}
/**
* Get the console command options.
*/
protected function getOptions()
{
return [
['force', null, InputOption::VALUE_NONE, 'Force the operation to run and ignore production warning.'],
];
}
/**
* Get the default confirmation callback.
* @return \Closure
*/
protected function getDefaultConfirmCallback()
{
2014-10-18 11:58:50 +02:00
return function () {
return true;
};
2014-05-14 23:24:20 +10:00
}
2014-10-18 11:58:50 +02:00
}