Skip to content

Commit 5bbc602

Browse files
committed
Add an uninstall command
1 parent a6693d2 commit 5bbc602

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

commands/web/drupal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use DrupalCoreDev\Command\CacheCommand;
2020
use DrupalCoreDev\Command\AdminLoginCommand;
2121
use DrupalCoreDev\Command\TestCommand;
2222
use DrupalCoreDev\Command\TestBrowserCommand;
23+
use DrupalCoreDev\Command\UninstallCommand;
2324

2425
if (PHP_SAPI !== 'cli') {
2526
return;
@@ -37,5 +38,6 @@ $application->add(new CacheCommand($loader));
3738
$application->add(new AdminLoginCommand($loader));
3839
$application->add(new TestCommand());
3940
$application->add(new TestBrowserCommand());
41+
$application->add(new UninstallCommand());
4042

4143
$application->run();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
#ddev-generated
3+
4+
namespace DrupalCoreDev\Command;
5+
6+
use Symfony\Component\Console\Command\Command;
7+
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Output\OutputInterface;
9+
use Symfony\Component\Filesystem\Filesystem;
10+
11+
class UninstallCommand extends Command {
12+
/**
13+
* {@inheritdoc}
14+
*/
15+
protected function configure() {
16+
$this->setName('uninstall')
17+
->setDescription('Uninstall Drupal by deleting settings.');
18+
}
19+
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
protected function execute(InputInterface $input, OutputInterface $output): int {
24+
$filesystem = new Filesystem();
25+
$settings = __DIR__ . '/../../../../sites/default/settings.php';
26+
$files = __DIR__ . '/../../../../sites/default/files';
27+
$filesystem->chmod($files . '/../', 0755);
28+
$filesystem->chmod($settings, 0777, 0000, true);
29+
$filesystem->remove($settings);
30+
$filesystem->chmod($files, 0777, 0000, true);
31+
$filesystem->remove($files);
32+
return 0;
33+
}
34+
}

install.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ project_files:
1717
- core-dev/src/Command/CacheCommand.php
1818
- core-dev/src/Command/TestCommand.php
1919
- core-dev/src/Command/TestBrowserCommand.php
20+
- core-dev/src/Command/UninstallCommand.php
2021

2122
post_install_actions:
2223
- cp core-dev/phpunit-chrome.xml ../core/phpunit.xml

0 commit comments

Comments
 (0)