{@inheritdoc}

@see PlatformCommand::getCurrentEnvironment()
767657
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->stdOut->writeln("<info>Syncing Platform.sh environment database to local</info>");

        /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
        $process = $this->getHelper('process');

        // If this is a Platform.sh project, get latest dump.
        // @todo: add proper provider integration
        if (Config::get('id')) {
            $process->mustRun($this->stdOut, [
              'platform',
              'sql-dump',
            ]);
        }

        $cd = getcwd();
        chdir(Platform::webDir());
        $process->run($this->stdOut, 'drush sqlc < ' . $input->getArgument('file'));
        chdir($cd);
    }
1061040
public function getCurrentEnvironmentName()
    {
        if (!empty($this->currentEnvironmentName)) {
            return $this->currentEnvironmentName;
        }

        // get current environments
        $environments = $this->applicationConfig->get('Application.Environments', false);

        if($environments){
            // get current url
            $currentUrl = $this->str($this->httpRequest()->getCurrentUrl());

            // loop over all registered environments in the config, and try to match the current based on the domain
            foreach ($environments as $eName => $e) {
                if ($currentUrl->contains($e->Domain)) {
                    $this->currentEnvironmentName = $eName;
                }
            }
        }

        if (empty($this->currentEnvironmentName)) {
            $this->currentEnvironmentName = 'Production';
        }

        return $this->currentEnvironmentName;
    }
113393
public function makeFromEnvironment()
    {
        $env = new EnvUtils();

        // Check that we have all variables we need
        if (!$env->hasBearerKey()) {
            throw new Exception(
                'TUTUM_AUTH is not set. Unable to create from environment'
            );
        }

        $client = new Client('', '');
        $client->setBearerKey($env->getBearerKey());

        return $client;
    }
461008
public function getEnvironment($config = null)
    {
        if ( ! $this->environment) {
            if (null == $config) {
                $config = $this->getConfig();
            }

            $this->environment = new Environment($config);
        }

        return $this->environment;
    }
605040
private function getEnvironment()
    {
        $paths         = $this->config->paths;
        $paths['root'] = $this->root;
        return new \Taniko\Saori\Generator\Environment(
            $this->getMaker(),
            $this->getTwigEnv("{$this->theme_dir}/twig"),
            $paths
        );
    }
440315
public static function GetEnvironment ($autoloadSystemConfig = FALSE) {
		if (static::$environment === NULL) {
			if ($autoloadSystemConfig) {
				if (static::GetSystem() === FALSE) 
					// if there is no system config, recognize environment only by very 
					// simple way - by server and client IP only
					static::EnvironmentDetectByIps();
			} else {
				static::EnvironmentDetectByIps();
			}
		}
		return static::$environment;
	}
1193462
protected function cleanEnvironments()
    {
        $environmentsWhichExist = array();
        foreach ($this->getEnvironments() as $key => $environment) {

            $msg = "Cleaning environment  from storage {$environment}";
            if (true == $this->vagrentExists($environment)) {
                $environmentsWhichExist[] = $environment;
                $msg = "Not cleaning from storage {$environment}";
            }
            $this->printLn($msg);
        }
        $this->setEnvironments($environmentsWhichExist);
        return $this;
    }
1194108
private function _translateCurrentInstance($environmentInfo)
    {
        $endpoints = [];

        $endpointsInfo = Utilities::tryGetKeysChainValue(
            $environmentInfo,
            'CurrentInstance',
            'Endpoints',
            'Endpoint'
        );

        if (!is_null($endpointsInfo)) {
            $endpoints = $this->_translateRoleInstanceEndpoints($endpointsInfo);
        }

        $currentInstance = new RoleInstance(
            $environmentInfo['CurrentInstance']['@attributes']['id'],
            $environmentInfo['CurrentInstance']['@attributes']['faultDomain'],
            $environmentInfo['CurrentInstance']['@attributes']['updateDomain'],
            $endpoints
        );

        foreach ($currentInstance->getInstanceEndpoints() as $endpoint) {
            $endpoint->setRoleInstance($currentInstance);
        }

        return $currentInstance;
    }
635935
public function getAllEnvironmentsSorted(?callable $sorter = null)
    {
        $environments = $this->findAll();

        if ($sorter) {
            usort($environments, $sorter);
        } else {
            usort($environments, $this->environmentSorter());
        }

        return $environments;
    }
163727
private function getSubmitAction(EnvironmentInterface $environment, $regardSelectMode = false)
    {
        if (!$regardSelectMode
            && $environment->getInputProvider()->hasParameter('select')
            && !$environment->getInputProvider()->hasValue('properties')
        ) {
            return 'select' . \ucfirst($environment->getInputProvider()->getParameter('select'));
        }

        if (null !== ($action = $this->determineAction($environment))) {
            return $action;
        }

        if ($regardSelectMode) {
            return $environment->getInputProvider()->getParameter('mode') ?: null;
        }

        return $environment->getInputProvider()->getParameter('select') ?
            'select' . \ucfirst($environment->getInputProvider()->getParameter('select')) : null;
    }
684700
public Environment getEnvironment()
    {
        Environment env = ((BaseApplication)this.getApplication()).getEnvironment();
        if (env == null)
            env = Environment.getEnvironment(null);   // Never
        return env;
    }
802617
public function getCurrentEnv():string
    {
        $f = new JsonListener();
        $result = $f->open(
            realpath(__DIR__."/../../../../../../../elements/config_files/core/framework.config.json")
        );
        return ($result->default_env);
    }
1252429
public static function GetClientIpEnvironnement() {
        $ipaddress = '';
        if (getenv('HTTP_CLIENT_IP'))
            $ipaddress = getenv('HTTP_CLIENT_IP');
        else if (getenv('HTTP_X_FORWARDED_FOR'))
            $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
        else if (getenv('HTTP_X_FORWARDED'))
            $ipaddress = getenv('HTTP_X_FORWARDED');
        else if (getenv('HTTP_FORWARDED_FOR'))
            $ipaddress = getenv('HTTP_FORWARDED_FOR');
        else if (getenv('HTTP_FORWARDED'))
            $ipaddress = getenv('HTTP_FORWARDED');
        else if (getenv('REMOTE_ADDR'))
            $ipaddress = getenv('REMOTE_ADDR');
        else
            $ipaddress = 'UNKNOWN';

        return $ipaddress;
    }
283984
public function getEnvOption($key, $default = null)
    {
        if (!array_key_exists('environments', $this->configuration) || !is_array($this->configuration['environments'])) {
            return $default;
        }

        if (!array_key_exists($this->environment, $this->configuration['environments'])) {
            return $default;
        }

        if (array_key_exists($key, $this->configuration['environments'][$this->environment])) {
            return $this->configuration['environments'][$this->environment][$key];
        }

        return $default;
    }
1089592
public function getCurrentDeployment(Environment $environment, $refresh = false)
    {
        $cacheKey = implode(':', ['current-deployment', $environment->project, $environment->id]);
        $data = $this->cache->fetch($cacheKey);
        if ($data === false || $refresh) {
            $deployment = $environment->getCurrentDeployment();
            $data = $deployment->getData();
            $data['_uri'] = $deployment->getUri();
            $this->cache->save($cacheKey, $data, $this->config->get('api.environments_ttl'));
        } else {
            $deployment = new EnvironmentDeployment($data, $data['_uri'], $this->getHttpClient(), true);
        }

        return $deployment;
    }
763792
public function getEnvironment()
    {
        if (!empty($this->environnement)) {
            $host      = gethostname();
            $authority = $this->request->getUri()->getAuthority();

            foreach ($this->environnement as $key => $env) {
                if (in_array($host, $env) || in_array($authority, $env)) {
                    return $key;
                }
            }
        }

        return '';
    }
115578
protected function environmentsDown($ignoreCurrentEnvironment=false)
    {
        foreach ($this->getEnvironments() as $environment) {
            if (true == $ignoreCurrentEnvironment 
                && $environment == $this->getCurrentEnvironment()
            ) {
                $this->printLn("Skipping current environment {$environment}");
            } else if (true == file_exists($environment)) {
                chdir($environment);
                $this->printLn("Attempting shutdown down vagrant in {$environment}");
                $output = '';
                $return = '';
                exec('vagrant halt', $output, $return);
                if (false == is_array($output)) {
                    $output = array($output);
                }
                if (0 != $return) {
                    $this->printLn("Error found, logged", 'warning');
                    $this->printLn(implode(', ', $output), 'warning', false);
                } else {
                    $this->printLn(implode(', ', $output), 'notice');
                }
            } else {
                $this->printLn("Dir not found {$environment}");

            }
        }
        chdir($this->pwd);
        return $this;
    }