@param string $site
@param string $env

@return \Acquia\Cloud\Api\Response\Databases

@throws \Guzzle\Http\Exception\ClientErrorResponseException

@see http://cloudapi.acquia.com/#GET__sites__site_envs__env_dbs-instance_route
329867
public function environmentDatabases($site, $env)
    {
        $variables = array(
            'site' => $site,
            'env' => $env,
        );
        $request = $this->get(array('{+base_path}/sites/{site}/envs/{env}/dbs.json', $variables));
        return new Response\Databases($request);
    }
984874
public function databases($site)
    {
        $variables = array('site' => $site);
        $request = $this->get(array('{+base_path}/sites/{site}/dbs.json', $variables));
        return new Response\DatabaseNames($request);
    }
995214
public function installDistroByProject($site, $env, $projectName, $version)
    {
        $source = 'http://ftp.drupal.org/files/projects/' . $projectName . '-' . $version . '-core.tar.gz';
        return $this->installDistro($site, $env, self::INSTALL_PROJECT, $source);
    }
507876
public function detectEnvironment($envs)
    {
        $args = isset($_SERVER['argv']) ? $_SERVER['argv'] : null;

        return $this['env'] = (new EnvironmentDetector())->detect($envs, $args);
    }
612300
private function _corsConfig(array $env)
    {
        if (!isset($env['auth.cors_config'])) {
            $cors_config = array(
                'origin' => $env['HTTP_ORIGIN'],
                'methods' => 'GET, POST, PUT, DELETE, OPTIONS',
                'allowCredentials' => true,
                'maxAge' => 86400,
                'allowHeaders' => 'X-Requested-With'
            );

            if (isset($env['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
                $cors_config['methods'] = $env['HTTP_ACCESS_CONTROL_REQUEST_METHOD'];
            }

            if (isset($env['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
                $cors_config['allowHeaders'] = $env['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'];
            }

        } else {
            $cors_config = $env['auth.cors_config'];
        }

        return $cors_config;
    }
224760
private function callDelCreaServer(string $env)
    {
        Server::delete(FEnv::get("framework.compiled")."$env/", 'directory');
        Server::create(FEnv::get("framework.compiled")."$env/", 'directory');
    }
510351
def call(env)
      if env[:method] == :get && env[:url].to_s.size > 2000
        env[:request_headers][HEADER] = 'GET'
        env[:request_headers]['Content-Type'] =
          'application/x-www-form-urlencoded'
        env[:body] = env[:url].query
        env[:url].query = nil
        env[:method] = :post
      end

      @app.call(env)
    end
802100
private function setEnvironment($env) {
    if (isset($this->environments[$env])) {
      $this->loadEnvironment($env);
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
422284
function(envs) {

  // Do not allow us to create the initial site from test or live
  delete envs.test;
  delete envs.live;

  // Map into a choices array
  var choices = [];
  _.map(envs, function(val, key) {
    choices.push({
      name: key,
      value: key,
      id: key,
      php: val.php_version || undefined,
      drush: val.drush_version || undefined
    });
  });

  // Sort nicely by name and return
  return _.sortBy(choices, 'name');

}
769677
public static function setConnection($con, $env = null) 
    {
        $env = self::selectEnvironment($env);
        self::$_connection[$env] = $con;

        // just send an exception when not on production mode
        if (in_array($env, array("development","test"))) {
            self::setErrorHandling(\PDO::ERRMODE_EXCEPTION);
        }
    }
1202184
protected function getFile($location)
	{
		if($location == 'production' && file_exists($envFile = $this->getPath().".env.php"))
		{
			return $envFile;
		}

		return $this->getPath().".env.{$location}.php";
	}
173765
protected function rsync($site_env_id, $src, $dest, array $rsyncOptions)
    {
        list($site, $env) = $this->getSiteEnv($site_env_id);
        $env_id = $env->getName();

        $siteInfo = $site->serialize();
        $site_id = $siteInfo['id'];

        // Stipulate the temporary directory to use iff the destination is remote.
        $tmpdir = '';
        if ($dest[0] == ':') {
            $tmpdir = '~/tmp';
        }

        $siteAddress = "$env_id.$site_id@appserver.$env_id.$site_id.drush.in:";

        $src = preg_replace('/^:/', $siteAddress, $src);
        $dest = preg_replace('/^:/', $siteAddress, $dest);

        // Get the rsync options string. If the user did not pass
        // in any mode options (e.g. '-r'), then add in the default.
        $rsyncOptionString = implode(' ', $rsyncOptions);
        if (!preg_match('/(^| )-[^-]/', $rsyncOptionString)) {
            $rsyncOptionString = "-rlIpz $rsyncOptionString";
        }
        // Add in a tmp-dir option if one was not already specified
        if (!empty($tmpdir) && !preg_match('/(^| )--temp-dir/', $rsyncOptionString)) {
            $rsyncOptionString = "$rsyncOptionString --temp-dir=$tmpdir --delay-updates";
        }

        $this->log()->notice('Running {cmd}', ['cmd' => "rsync $rsyncOptionString $src $dest"]);
        $this->passthru("rsync $rsyncOptionString --ipv4 --exclude=.git -e 'ssh -p 2222' '$src' '$dest' ");
    }
547872
public function addDomain($site, $env, $domain)
    {
      $variables = array(
        'site' => $site,
        'env' => $env,
        'domain' => $domain,
      );
      $request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/domains/{domain}.json', $variables));
      return new Response\Task($request);
    }
1374393
protected function getSearchDirs(/*# string */ $env)/*# : array */
    {
        if (!isset($this->sub_dirs[$env])) {
            $this->sub_dirs[$env] = $this->buildSearchDirs($env);
        }
        return $this->sub_dirs[$env];
    }
792734
public function evaluate(EnvironmentInterface $env)
    {
        $qb = $env->queryBuilder;

        $paramName = $env->newParamName();
        $paramValue = $env->newParamName();

        $paramContent = $env->newParamName();
        $paramVs = $env->newParamName();
        $paramValues = $env->newParamName();
        $paramAttribute = $env->newParamName();

        $subQuery = $env->cloneQueryBuilder();

        $rootAliases = $subQuery->getRootAliases();
        $subQuery
            ->innerJoin($rootAliases[0].'.valueSet', $paramVs)
            ->innerJoin($paramVs.'.values', $paramValues)
            ->innerJoin($paramValues.'.attribute', $paramAttribute)
            ->andWhere($paramAttribute.'.name = :'.$paramName);

        switch ($this->operator) {
            case 'equals':
                $subQuery->andWhere($paramValues.'.value = :'.$paramValue);
                $qb->setParameter($paramValue, $this->getRight()->getValue());
                break;
            case 'notequals':
                $subQuery->andWhere($paramValues.'.value <> :'.$paramValue);
                $qb->setParameter($paramValue, $this->getRight()->getValue());
                break;
            case 'contains':
                $subQuery->andWhere($paramValues.'.value LIKE :'.$paramValue);
                $qb->setParameter($paramValue, '%'. $this->getRight()->getValue().'%');
                break;
        }

        $qb
            ->andWhere($qb->expr()->in('a', $subQuery->getDQL()))
            ->setParameter($paramName, $this->getAttribute())
        ;
    }
217331
public static function create($method, $path, array $env = array())
    {
        $request = new self($method, $path);

        if (function_exists('getallheaders')) {
            $request->headers = getallheaders();
        } else {
            // TODO: filter array keys by their prefix, consider adding an extension function for this.
            $request->headers = self::createHeadersFromServerGlobal($env);
        }

        if (isset($env['_SERVER'])) {
            $request->serverParameters = $env['_SERVER'];
        } else {
            $request->serverParameters = $env;
        }
        $request->parameters = isset($env['_REQUEST']) ? $env['_REQUEST'] : array();
        $request->queryParameters = isset($env['_GET']) ? $env['_GET'] : array();
        $request->bodyParameters = isset($env['_POST']) ? $env['_POST'] : array();
        $request->cookieParameters = isset($env['_COOKIE']) ? $env['_COOKIE'] : array();
        $request->sessionParameters = isset($env['_SESSION']) ? $env['_SESSION'] : array();

        return $request;
    }
797765
public static function normalize($env)
    {
        $env += ['PHP_SAPI' => PHP_SAPI];

        if (isset($env['SCRIPT_URI'])) {
            $env['HTTPS'] = strpos($env['SCRIPT_URI'], 'https://') === 0;
        } elseif (isset($env['HTTPS'])) {
            $env['HTTPS'] = (!empty($env['HTTPS']) && $env['HTTPS'] !== 'off');
        }

        if (isset($env['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
            $env['REQUEST_METHOD'] = $env['HTTP_X_HTTP_METHOD_OVERRIDE'];
        }

        if (isset($env['REDIRECT_HTTP_AUTHORIZATION'])) {
            $env['HTTP_AUTHORIZATION'] = $env['REDIRECT_HTTP_AUTHORIZATION'];
        }

        foreach (['HTTP_X_FORWARDED_FOR', 'HTTP_PC_REMOTE_ADDR', 'HTTP_X_REAL_IP'] as $key) {
            if (isset($env[$key])) {
                $addrs = explode(', ', $env[$key]);
                $env['REMOTE_ADDR'] = reset($addrs);
                break;
            }
        }

        if (empty($env['SERVER_ADDR']) && !empty($env['LOCAL_ADDR'])) {
            $env['SERVER_ADDR'] = $env['LOCAL_ADDR'];
        }

        if ($env['PHP_SAPI'] === 'isapi' && isset($env['PATH_TRANSLATED']) && isset($env['SCRIPT_NAME'])) {
            $env['SCRIPT_FILENAME'] = str_replace('\\\\', '\\', $env['PATH_TRANSLATED']);
            $env['DOCUMENT_ROOT'] = substr($env['SCRIPT_FILENAME'], 0, -strlen($env['SCRIPT_NAME']));
        }

        return $env;
    }