This repository has been archived by the owner on Nov 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdelete.rum.inc
86 lines (72 loc) · 2.46 KB
/
delete.rum.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* @file
* Contains a logic to delete a project created with Rum or adhering to the Rum
* conventions of how a project is set up in your local environment.
*/
use Rum\Component\Rum\Rum;
use Rum\Component\Rum\RumDatabase;
use Rum\Component\Rum\RumHosts;
use Rum\Component\Rum\RumWebServer;
use Rum\Component\Rum\RumFileSystem;
use Rum\Component\Rum\RumDrush;
function drush_rum_delete($project_name = '') {
if (count(drush_get_arguments()) > 2) {
drush_log(dt('You provided too many arguments.'), 'error');
return FALSE;
}
// Precedence to the @alias settings. If the project was not generated with Rum,
// we should still be able to delete it. So we use the options and arguments.
$alias_project_name = drush_get_option('rum_project_name', '');
if (!empty($alias_project_name)) {
$project_name = $alias_project_name;
}
if (empty($project_name)) {
drush_set_error(dt('No project specified. Pass a project name as an argument.'));
}
$alias_project_dir = drush_get_option('rum_project_dir', '');
if (!empty($alias_project_dir)) {
$project_dir = $alias_project_dir;
} else {
$project_dir = drush_get_option('project-dir', '');
if (empty($project_dir)) {
$project_dir = $project_name;
}
}
try {
$rum = new Rum($project_name, $project_dir);
// Environment
$environment = drush_get_option('rum-environment', '');
$rum->setEnviroment($environment);
// Delete the db user & db
global $databases;
$rum = new RumDatabase($rum);
$db_user = $databases['default']['default']['username'];
$rum->setProjectDbUser($databases['default']['default']['username'], $databases['default']['default']['password']);
$rum->setProjectDb($databases['default']['default']['database']);
$result = drush_confirm(dt('Do you really want to drop the database?'));
if ($result) {
$rum->dropUser();
$rum->dropDatabase();
} else {
return drush_user_abort();
}
// Delete the hosts reference
$rum = new RumHosts($rum);
$rum->removeHostsEntry();
// Delete the vhost configuration
// Delete the link
$rum = new RumWebServer($rum);
$rum->removeVhost();
// Restart webserver
$rum->restart();
// Delete the entire project folder
$rum = new RumFileSystem($rum);
$rum->RemoveProjectDir();
// Delete the drushrc file
$rum = new RumDrush($rum);
$rum->removeDrush();
} catch (Exception $e) {
drush_set_error($e->getMessage());
}
}