Commit ee14c7f1 authored by drumm's avatar drumm Committed by Neil Drumm

Remove redundant constants

parent dd949607
<?php
function drush_db_provision_delete_validate() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
provision_service('db')->connect();
}
}
......@@ -12,7 +12,7 @@ function drush_db_provision_delete_validate() {
* This will drop the database, revoke the privileges and flush the privileges.
*/
function drush_db_provision_delete() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
provision_service('db')->destroy_site_database();
}
}
<?php
function drush_http_provision_delete() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
provision_service('http')->delete_site_config();
}
if (PROVISION_CONTEXT_PLATFORM) {
if (d()->type === 'platform') {
$sites = provision_drupal_find_sites();
if($sites) {
drush_set_error(dt('Existing sites were found on this platform. These sites will need to be deleted before this platform can be deleted.'));
......
......@@ -2,7 +2,7 @@
function drush_provision_drupal_provision_delete_validate($backup_file = NULL) {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
_provision_drupal_valid_site();
}
}
......@@ -11,7 +11,7 @@ function drush_provision_drupal_provision_delete_validate($backup_file = NULL) {
* Before starting to delete the site, make a backup
*/
function drush_provision_drupal_pre_provision_delete($backup_file = NULL) {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
drush_set_option('force', true, 'process');
drush_invoke("provision-backup", $backup_file);
drush_unset_option('force', 'process');
......@@ -24,14 +24,14 @@ function drush_provision_drupal_pre_provision_delete($backup_file = NULL) {
* This can't be rolled back. so won't even try.
*/
function drush_provision_drupal_provision_delete() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
_provision_recursive_delete(d()->root . '/sites/' . d()->uri);
// we remove the aliases even if redirection is enabled as a precaution
// if redirection is enabled, keep silent about errors
_provision_drupal_delete_aliases(drush_get_option('aliases', array()), drush_get_option('redirection'));
drush_set_option('installed', FALSE, 'site');
}
if (PROVISION_CONTEXT_PLATFORM) {
if (d()->type === 'platform') {
$sites = provision_drupal_find_sites();
if($sites) {
drush_set_error(dt('Existing sites were found on this platform. These sites will need to be deleted before this platform can be deleted.'));
......
......@@ -66,21 +66,11 @@ function _provision_context_init() {
return TRUE;
}
// define('PROVISION_CONTEXT_SITE', (d()->type == 'site') ? TRUE : FALSE);
// define('PROVISION_CONTEXT_PLATFORM', !PROVISION_CONTEXT_SITE);
$context = d()->type;
if (($context === 'platform' || $context === 'site') && drush_bootstrap_validate(DRUSH_BOOTSTRAP_DRUPAL_ROOT)) {
if ((d()->type === 'platform' || d()->type === 'site') && drush_bootstrap_validate(DRUSH_BOOTSTRAP_DRUPAL_ROOT)) {
// i don't think i should be bootstrapping here yet ... but i have no choice yet.
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_ROOT);
}
define('PROVISION_CONTEXT_SERVER', $context === 'server');
define('PROVISION_CONTEXT_PLATFORM', $context === 'platform');
define('PROVISION_CONTEXT_SITE', $context === 'site');
drush_log(dt('Using context @context', array('@context' => $context)));
$is_run = TRUE;
}
......@@ -96,7 +86,7 @@ function provision_drupal_drush_exit() {
$command = explode(" ", $command['command']);
if (preg_match("/^provision-/", $command[0])) {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
if (drush_get_option('installed')) {
// dont generate the drushrc.php on provision-save commands.
if (!preg_match("/^provision-save/", $command[0])) {
......@@ -105,7 +95,7 @@ function provision_drupal_drush_exit() {
}
}
}
elseif (PROVISION_CONTEXT_PLATFORM) {
elseif (d()->type === 'platform') {
// Generate a drushrc.php for the platform unless it's being deleted
if (!preg_match("/^provision-delete/", $command[0])) {
provision_save_platform_data();
......@@ -119,7 +109,7 @@ function provision_drupal_drush_exit() {
* This prints out a message to that effect.
*/
function _provision_drupal_url_required() {
if (PROVISION_CONTEXT_PLATFORM) {
if (d()->type === 'platform') {
drush_set_error('PROVISION_REQUIRES_URL');
}
}
......@@ -130,7 +120,7 @@ function _provision_drupal_url_required() {
* This will return an error for sites that haven't been created yet
*/
function _provision_drupal_valid_site() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
if (!_provision_drupal_site_exists()) {
drush_set_error('PROVISION_DRUPAL_SITE_NOT_FOUND');
}
......@@ -156,7 +146,7 @@ function _provision_drupal_site_exists() {
* This will return an error for sites that haven't been installed yet
*/
function _provision_drupal_valid_installed_site() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
if (!_provision_drupal_site_installed()) {
drush_set_error('PROVISION_DRUPAL_SITE_NOT_FOUND');
}
......@@ -164,7 +154,7 @@ function _provision_drupal_valid_installed_site() {
}
function _provision_drupal_valid_not_installed_site() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
if (_provision_drupal_site_installed()) {
drush_set_error('PROVISION_DRUPAL_SITE_INSTALLED');
}
......@@ -280,7 +270,7 @@ function _provision_drupal_create_directories($url = NULL, $profile = NULL) {
* Runs an external script to reload all the various drupal caches
*/
function _provision_drupal_rebuild_caches() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
drush_include_engine('drupal', 'clear');
}
}
......@@ -380,7 +370,7 @@ function _provision_drupal_get_cvs_versions($files) {
* Create and remove symlinks for each of the possible domain aliases of an existing site
*/
function _provision_drupal_maintain_aliases() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
// First we delete all the old aliases
drush_set_option('aliases', drush_get_option('aliases'), 'site');
_provision_drupal_delete_aliases(drush_get_option('aliases', array(), 'site'), false);
......
......@@ -6,7 +6,7 @@
* Disable an enabled and installed site
*/
function drush_provision_drupal_provision_verify_validate() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
provision_prepare_environment();
......@@ -25,7 +25,7 @@ function drush_provision_drupal_provision_verify_validate() {
* implementation of provision_verify
*/
function drush_provision_drupal_provision_verify() {
if (PROVISION_CONTEXT_SERVER) {
if (d()->type === 'server') {
provision_service('file')->create_dir(d()->config_path, dt('Provision configuration'), 0711);
provision_service('file')->create_dir(d()->config_path . '/includes', dt('Provision PHP configuration'), 0711);
if (!provision_service('file')->exists(d()->config_path . '/includes/global.inc')->succeed('Global configuration file exists')->status()) {
......@@ -36,7 +36,7 @@ function drush_provision_drupal_provision_verify() {
}
provision_service('file')->create_dir(d()->backup_path, dt('Backup'), 0700);
}
elseif (PROVISION_CONTEXT_PLATFORM) {
elseif (d()->type === 'platform') {
provision_service('file')->writable(d()->root . '/sites')
->succeed('Drupal sites directory @path is writable by the provisioning script')
->fail('Drupal sites directory @path is not writable by the provisioning script', 'PROVISION_SITES_DIR_NOT_WRITABLE');
......@@ -45,7 +45,7 @@ function drush_provision_drupal_provision_verify() {
drush_log(dt("This platform is running @short_name @version", array('@short_name' => 'drupal', '@version' => VERSION)));
drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
}
elseif (PROVISION_CONTEXT_SITE) {
elseif (d()->type === 'site') {
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
// This is the actual drupal provisioning requirements.
_provision_drupal_create_directories();
......@@ -71,7 +71,7 @@ class provisionConfig_global_settings extends provisionConfig {
* Implementation of hook_provision_post_verify
*/
function drush_provision_drupal_post_provision_verify() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
_provision_drupal_rebuild_caches();
drush_set_option('aliases', drush_get_option('aliases'), 'site');
drush_set_option('redirection', drush_get_option('redirection'), 'site');
......
......@@ -3,7 +3,7 @@
// $Id$
function drush_provision_ssl_post_provision_verify() {
if (PROVISION_CONTEXT_SITE) {
if (d()->type === 'site') {
drush_set_option('ssl', drush_get_option('ssl'), 'site');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment