Exemplo n.º 1
0
 public function run()
 {
     if (!parent::run()) {
         return false;
     }
     if (empty($this->site_info->root_path) || $this->site_info->environment !== 'drupal') {
         throw new \Exception("Unable to determine the Drupal root directory. Make sure you are running this command inside a Drupal website's root directory.");
     }
     $env = new \GR\ServerEnv($this->site_info->root_path);
     $env->requireApacheConfFile();
     $env->setEnvVars();
     if (getenv("APP_ENV") === FALSE) {
         throw new \Exception("No APP_ENV environment variable is set for this site.");
     }
     if (getenv("APP_NAME") === FALSE) {
         throw new \Exception("No APP_NAME environment variable is set for this site.");
     }
     $args = implode(' ', $this->args);
     $command = "drush {$args}";
     passthru($command);
 }
Exemplo n.º 2
0
 public static function get_database_credentials($root_path = NULL)
 {
     $root_path = isset($root_path) ? $root_path : getcwd();
     $env = new \GR\ServerEnv($root_path);
     $env->setEnvVars($throw_exception = FALSE);
     include "{$root_path}/sites/default/settings.php";
     $database_credentials = array();
     if (isset($databases)) {
         // Drupal 7
         $database_credentials = array('database' => $databases['default']['default']['database'], 'username' => $databases['default']['default']['username'], 'password' => $databases['default']['default']['password'], 'host' => $databases['default']['default']['host']);
     } elseif ($db_url) {
         // Drupal 6
         $regex = "|^(.*?)://(.*?):(.*?)@(.*?)/(.*?)\$|";
         $matches = array();
         preg_match($regex, $db_url, $matches);
         if (!empty($matches)) {
             $database_credentials = array('database' => $matches[5], 'username' => $matches[2], 'password' => $matches[3], 'host' => $matches[4]);
         }
     }
     return $database_credentials;
 }
 public function check_database_name()
 {
     if (isset($this->clobber) && $this->clobber) {
         return TRUE;
     }
     $db_name = strtolower($this->database_credentials['database']);
     $env = new \GR\ServerEnv($this->site_info->root_path);
     $env->setEnvVars($throw_exception = FALSE);
     if (strpos($db_name, 'prod') !== FALSE || getEnv('APP_ENV') === 'prod') {
         return FALSE;
     }
     if (strpos($db_name, 'stag') === FALSE && strpos($db_name, 'dev') === FALSE && strpos($db_name, 'local') === FALSE) {
         return 'CONFIRM';
     }
     return TRUE;
 }