Exemplo n.º 1
0
 public static function createDirectory($original_path, $type, Environment $environment)
 {
     $paths = pathinfo($original_path);
     $dirname = realpath($paths['dirname']);
     if (!$dirname || !is_dir($dirname) || !is_readable($dirname)) {
         if (@mkdir($original_path, 0777, true) === true) {
             $realpath = $original_path;
         } else {
             return $environment->set_error(ucfirst($type) . " parent path '{$paths['dirname']}' does not exist.  Please correct the path or create the directory.");
         }
     }
     $path = $dirname . '/' . $paths['basename'];
     $realpath = realpath($path);
     if ($realpath === false || !file_exists($realpath)) {
         if (@mkdir($path, 0777, true) === true) {
             $realpath = $path;
         } else {
             return $environment->set_error("Unable to create directory '{$path}'.  Please make the directory manually or check the permissions of the parent directory.");
         }
     } elseif (!is_readable($realpath) || !is_writable($realpath)) {
         @chmod($realpath, 0777);
     }
     if (substr($realpath, -1) != '/') {
         $realpath .= '/';
     }
     if (is_dir($realpath) && is_readable($realpath) && is_writable($realpath)) {
         return $realpath;
     } else {
         return $environment->set_error("Path to directory for {$type} is not valid.  Please correct the path or create the directory and check that is readable and writable.");
     }
 }
Exemplo n.º 2
0
 public function setDefaultEnv($environment)
 {
     $env = new Environment();
     if (is_object($env->add($environment))) {
         $this->currentEnviroment = $environment;
     }
 }
 /**
  * Change the user's environment-level role.
  *
  * @param Environment $environment
  * @param string      $newRole The new role ('admin', 'contributor',
  *                             or 'viewer').
  */
 public function changeEnvironmentRole(Environment $environment, $newRole)
 {
     if (!in_array($newRole, ['admin', 'contributor', 'viewer'])) {
         throw new \InvalidArgumentException("Invalid role: {$newRole}");
     }
     $this->sendRequest($environment->getUri() . '/access/' . $this->id, 'patch', ['json' => ['role' => $newRole]]);
 }
Exemplo n.º 4
0
 public function testGet()
 {
     $get = array('n' => 'v');
     $env = new Environment($get, array(), array());
     $this->assertEquals('v', $env->get('n'));
     $this->assertNull($env->get('not-existed-param'));
 }
Exemplo n.º 5
0
 /**
  * Proxy method that handles return of assets instead of instant output.
  *
  * @param  Environment $env
  * @param  string $method
  * @param  string|null $options Assets CollectionName
  * @return string
  */
 protected function getAssetsOutput(Environment $env, $method, $options = null)
 {
     $env->getDi()->get('assets')->useImplicitOutput(false);
     $result = $env->getDi()->get('assets')->{$method}($options);
     $env->getDi()->get('assets')->useImplicitOutput(true);
     return $result;
 }
Exemplo n.º 6
0
 function setEnvironment(Environment $env)
 {
     $this->environment = $env;
     $env->setLoader($this);
     Controller::setEnvironment($env);
     return $this;
 }
 /**
  * Test that the parser gets its values from the $_SERVER and $_ENV environment variables
  */
 public function testUsesEnvironmentVariables()
 {
     $_SERVER['foo'] = 'bar';
     $_ENV['test'] = 'example';
     $configuration = $this->parser->parse();
     $this->assertArrayHasKey('foo', $configuration);
     $this->assertArrayHasKey('test', $configuration);
 }
Exemplo n.º 8
0
 public static function saveCachedEnvironmentObject()
 {
     if (!file_exists(DIR_FILES_CACHE . '/' . FILENAME_ENVIRONMENT_CACHE)) {
         $env = new Environment();
         $env->getOverrides();
         @file_put_contents(DIR_FILES_CACHE . '/' . FILENAME_ENVIRONMENT_CACHE, serialize($env));
     }
 }
Exemplo n.º 9
0
 static function init($ApiKey, Environment $env)
 {
     if ($env->getBaseUrl() != Environment::PROD and $env->getBaseUrl() != Environment::TEST and $env->getBaseUrl() != Environment::DEV) {
         throw new \InvalidArgumentException('$env must be Apruve\\Environment::PROD or Apruve\\Environment::TEST to be valid.');
     }
     ClientStorage::setEnvironment($env);
     ClientStorage::setApiKey($ApiKey);
     return new Client();
 }
Exemplo n.º 10
0
 public function register(Environment $environment)
 {
     $env = $environment->getEnv();
     foreach ($env['packages'] as $k => $e) {
         if ($k !== "Syph") {
             $this->app_container_config[$k] = array("app_path_conf" => $e . DS . "Config" . DS . "config.php");
         }
     }
 }
Exemplo n.º 11
0
 /**
  * Create a normalized tree of UploadedFile instances from the Environment.
  *
  * @param Environment $env The environment
  *
  * @return array|null A normalized tree of UploadedFile instances or null if none are provided.
  */
 public static function createFromEnvironment(Environment $env)
 {
     if (is_array($env['slim.files']) && $env->has('slim.files')) {
         return $env['slim.files'];
     } elseif (isset($_FILES)) {
         return static::parseUploadedFiles($_FILES);
     }
     return [];
 }
Exemplo n.º 12
0
 /**
  * Tests if module was activated.
  *
  * @dataProvider providerModuleActivation
  *
  * @param array  $aInstallModules
  * @param string $sModule
  * @param array  $aResultToAsserts
  */
 public function testModuleActivation($aInstallModules, $sModule, $aResultToAsserts)
 {
     $oEnvironment = new Environment();
     $oEnvironment->prepare($aInstallModules);
     $oModule = oxNew('oxModule');
     $oModule->load($sModule);
     $this->deactivateModule($oModule);
     $this->activateModule($oModule);
     $this->runAsserts($aResultToAsserts);
 }
Exemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function render(Request $request, Response $response)
 {
     if (!$this->environment->isSilent()) {
         header('HTTP/1.1 ' . $response->getStatusCode() . ' ' . $response->getStatusMessage());
         foreach ($response->getHeaders() as $name => $value) {
             header($name . ': ' . $value);
         }
     }
     echo $this->createTemplate($response);
 }
Exemplo n.º 14
0
 /**
  * Checks the site's mode and suggests SFTP if it is not set.
  *
  * @param Environment $environment Environment object to check mode of
  * @return void
  */
 protected function checkConnectionMode($environment)
 {
     if ($environment->getConnectionMode() != 'sftp') {
         $message = 'Note: This environment is in read-only Git mode. If you ';
         $message .= 'want to make changes to the codebase of this site ';
         $message .= '(e.g. updating modules or plugins), you will need to ';
         $message .= 'toggle into read/write SFTP mode first.';
         $this->log()->warning($message);
     }
 }
 public function testModulesWithoutMetadataShouldBeAddToCleanupAllModulesWithMetadata()
 {
     // modules to be activated during test preparation
     $aInstallModules = array('extending_1_class');
     $oEnvironment = new Environment();
     $oEnvironment->prepare($aInstallModules);
     $oModuleList = oxNew('oxModuleList');
     $aGarbage = $oModuleList->getDeletedExtensions();
     $this->assertSame(array(), $aGarbage);
 }
Exemplo n.º 16
0
 /**
  * {@inheritdoc}
  *
  * @throws \Icicle\File\Exception\FileException
  * @throws \Icicle\Exception\InvalidArgumentError
  */
 public function run(Environment $environment)
 {
     if ('f' === $this->operation[0]) {
         if ('fopen' === $this->operation) {
             $file = new File($this->args[0], $this->args[1]);
             $id = $file->getId();
             $environment->set($this->makeId($id), $file);
             return [$id, $file->stat()['size'], $file->inAppendMode()];
         }
         if (null === $this->id) {
             throw new FileException('No file ID provided.');
         }
         if (!$environment->exists($this->id)) {
             throw new FileException('No file handle with the given ID has been opened on the worker.');
         }
         if (!($file = $environment->get($this->id)) instanceof File) {
             throw new FileException('File storage found in inconsistent state.');
         }
         switch ($this->operation) {
             case 'fread':
             case 'fwrite':
             case 'fseek':
             case 'fstat':
             case 'ftruncate':
                 return [$file, substr($this->operation, 1)](...$this->args);
             case 'fclose':
                 $environment->delete($this->id);
                 return true;
             default:
                 throw new InvalidArgumentError('Invalid operation.');
         }
     }
     switch ($this->operation) {
         case 'stat':
         case 'unlink':
         case 'rename':
         case 'copy':
         case 'link':
         case 'symlink':
         case 'readlink':
         case 'isfile':
         case 'isdir':
         case 'mkdir':
         case 'lsdir':
         case 'rmdir':
         case 'chmod':
         case 'chown':
         case 'chgrp':
             return [$this, $this->operation](...$this->args);
         default:
             throw new InvalidArgumentError('Invalid operation.');
     }
 }
Exemplo n.º 17
0
 static function compileTwigMoreHaml($hamlstr, $options, $moreOptions = null)
 {
     static $env;
     if (!is_null($options)) {
         $env = new Environment('twig_more', $options);
     }
     if ($env) {
         return $env->compileString($hamlstr, $moreOptions);
     } else {
         throw new Exception\MoreException('plz supply 2nd arg when calling this func first time');
     }
 }
Exemplo n.º 18
0
 /**
  * For fetching body/params sent via PUT|DELETE|PATCH Http method.
  *
  * @param bool $asResource
  *
  * @return Param|resource|boolean
  */
 public function streamInput($asResource = false)
 {
     if (0 === strpos($this->env->getRequestHeader('CONTENT_TYPE'), 'application/x-www-form-urlencoded') && in_array($this->env->data()->get('REQUEST_METHOD', 'GET'), array('PUT', 'DELETE', 'PATCH'))) {
         if ($asResource === true) {
             return $this->getContent($asResource);
         }
         $body = array();
         parse_str($this->getContent(), $body);
         return new Param($body);
     }
     return false;
 }
 /**
  * Test check shop environment after activation of module with similar name as deactivated module
  *
  * @dataProvider providerModuleReactivation
  *
  * @param array  $installModules
  * @param string $sReactivateModule
  * @param array  $aResultToAssert
  */
 public function testModuleActivateWithSimilarName($installModules, $sReactivateModule, $aResultToAssert)
 {
     $environment = new Environment();
     $environment->prepare($installModules);
     foreach ($installModules as $sModule) {
         $oModule = oxNew('oxModule');
         $this->deactivateModule($oModule, $sModule);
     }
     $oModule = oxNew('oxModule');
     $this->activateModule($oModule, $sReactivateModule);
     $this->runAsserts($aResultToAssert);
 }
 public function testModulesWithMissingFiles()
 {
     $this->markTestSkipped('Currently we are not checking module files.');
     // modules to be activated during test preparation
     $aInstallModules = array('with_1_extension', 'with_2_files');
     $oEnvironment = new Environment();
     $oEnvironment->prepare($aInstallModules);
     $oModuleList = oxNew('oxModuleList');
     $aGarbage = $oModuleList->getDeletedExtensions();
     $aExpect = array('with_1_extension' => array('extensions' => array('oxarticle' => 'with_1_extension/mybaseclass')), 'with_2_files' => array('files' => array('myexception' => 'with_2_files/core/exception/myexception.php', 'myconnection' => 'with_2_files/core/exception/myconnection.php')));
     $this->assertSame($aExpect, $aGarbage);
 }
 /**
  * Test check shop environment after module deactivation in subshop.
  *
  * @dataProvider providerModuleDeactivation
  *
  * @param array  $aInstallModules
  * @param string $sModuleId
  * @param array  $aResultToAssert
  */
 public function testModuleDeactivationInSubShop($aInstallModules, $sModuleId, $aResultToAssert)
 {
     if ($this->getTestConfig()->getShopEdition() != 'EE') {
         $this->markTestSkipped("This test case is only actual when SubShops are available.");
     }
     $oModule = oxNew('oxModule');
     $oEnvironment = new Environment();
     $oEnvironment->prepare($aInstallModules);
     $oEnvironment->setShopId(2);
     $oEnvironment->activateModules($aInstallModules);
     $this->deactivateModule($oModule, $sModuleId);
     $this->runAsserts($aResultToAssert);
 }
Exemplo n.º 22
0
 /**
  * Test check shop module deactivation
  */
 public function testModuleDeactivate()
 {
     $oConfig = oxRegistry::getConfig();
     $sState = $oConfig->getConfigParam('sTestDeactivateEvent');
     $this->assertSame(null, $sState, 'No events should have been executed till now');
     $oEnvironment = new Environment();
     $oEnvironment->prepare(array('with_events'));
     $oModule = oxNew('oxModule');
     $oModule->load('with_events');
     $this->deactivateModule($oModule);
     $sState = $oConfig->getConfigParam('sTestDeactivateEvent');
     $this->assertEquals("Deactivate", $sState, 'onDeactivate event was not called.');
 }
 /**
  * Tests if module was activated.
  */
 public function testVersionNotify()
 {
     $oEnvironment = new Environment();
     $oEnvironment->prepare(array('extending_1_class', 'extending_1_class_3_extensions', 'with_everything'));
     /** @var oxOnlineModuleVersionNotifierCaller|PHPUnit_Framework_MockObject_MockObject $oCaller */
     $oCaller = $this->getMock('oxOnlineModuleVersionNotifierCaller', array('doRequest'), array(), '', false);
     $oCaller->expects($this->any())->method('doRequest')->with($this->equalTo($this->getExpectedRequest()));
     $oModuleList = oxNew('oxModuleList');
     $sModuleDir = realpath(dirname(__FILE__)) . '/testData/modules';
     $oModuleList->getModulesFromDir($sModuleDir);
     $oNotifier = new oxOnlineModuleVersionNotifier($oCaller, $oModuleList);
     $oNotifier->versionNotify();
 }
Exemplo n.º 24
0
 /**
  * merges config files of each module imported via config.ini[modules] to one file and loads it
  * considering current environment [dev, production, ...] - separate config file for each
  * uses Nette/Cache for invalidation when one (or more) of config files changed
  *
  * @param string|null  filepath
  * @return Config
  */
 public static function load($baseConfigFile = null)
 {
     if ($baseConfigFile === null) {
         $baseConfigFile = Environment::expand(Environment::getConfigurator()->defaultConfigFile);
     }
     $envName = Environment::getName();
     Environment::setVariable('tempDir', VAR_DIR . '/cache');
     $cache = Environment::getCache('config');
     $key = "config[{$envName}]";
     if (!isset($cache[$key])) {
         // najviac casu zabera load, tak az tu, ked ho je treba
         $appConfig = Environment::loadConfig($baseConfigFile);
         $configs = array(Config::fromFile($baseConfigFile, $envName)->toArray());
         $configPaths = array($baseConfigFile);
         foreach ($appConfig->modules as $c) {
             $configPaths[] = $path = MODULES_DIR . "/{$c}Module/config.ini";
             if (file_exists($path)) {
                 $configs[] = Config::fromFile($path, $envName)->toArray();
             }
         }
         $arrayConfig = call_user_func_array('array_merge_recursive', $configs);
         $cache->save($key, $arrayConfig, array('files' => $configPaths));
     }
     return Environment::loadConfig(new Config($cache[$key]));
 }
Exemplo n.º 25
0
 public function loadPlugin($app, $folder, $optional = false)
 {
     if (!file_exists(Util::getRootPath() . "{$app}/{$folder}/plugin.xml") and !$optional) {
         throw new Exception("Required plugin {$app}/{$folder} not available (1)");
     }
     if (!file_exists(Util::getRootPath() . "{$app}/{$folder}/plugin.xml")) {
         return false;
     }
     $xml = new XMLPlugin(Util::getRootPath() . "{$app}/{$folder}/plugin.xml");
     $allowedPlugins = Environment::getS("allowedPlugins", false);
     $extraPlugins = Environment::getS("pluginsExtra", false);
     $allow = false;
     if ($allowedPlugins !== false and in_array($xml->registerClassName(), $allowedPlugins)) {
         $allow = true;
     }
     if ($extraPlugins !== false and in_array($xml->registerClassName(), $extraPlugins)) {
         $allow = true;
     }
     if ($allowedPlugins !== false and !$allow) {
         if (!$optional) {
             throw new Exception("Required plugin {$app}/{$folder} not available (2)");
         }
         return false;
     }
     require_once Util::getRootPath() . "{$app}/{$folder}/" . $xml->registerClassName() . ".class.php";
     $this->addClassPath(Util::getRootPath() . "{$app}/{$folder}");
     return true;
 }
Exemplo n.º 26
0
 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_maintenance_mode');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->headline = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceMode'];
     $objTemplate->isActive = $this->isActive();
     try {
         $driver = \System::getContainer()->get('lexik_maintenance.driver.factory')->getDriver();
         $isLocked = $driver->isExists();
     } catch (\Exception $e) {
         return '';
     }
     // Toggle the maintenance mode
     if (\Input::post('FORM_SUBMIT') == 'tl_maintenance_mode') {
         if ($isLocked) {
             $driver->unlock();
         } else {
             $driver->lock();
         }
         $this->reload();
     }
     if ($isLocked) {
         $objTemplate->class = 'tl_confirm';
         $objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['maintenanceEnabled'];
         $objTemplate->submit = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceDisable'];
     } else {
         $objTemplate->class = 'tl_info';
         $objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['maintenanceDisabled'];
         $objTemplate->submit = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceEnable'];
     }
     return $objTemplate->parse();
 }
Exemplo n.º 27
0
 /**
  * Do not show the module if no calendar has been selected
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var \BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['calendar'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->cal_calendar = $this->sortOutProtected(deserialize($this->cal_calendar, true));
     // Return if there are no calendars
     if (!is_array($this->cal_calendar) || empty($this->cal_calendar)) {
         return '';
     }
     $this->strUrl = preg_replace('/\\?.*$/', '', \Environment::get('request'));
     $this->strLink = $this->strUrl;
     if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) {
         /** @var \PageModel $objTarget */
         $this->strLink = $objTarget->getFrontendUrl();
     }
     return parent::generate();
 }
Exemplo n.º 28
0
 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     /** @var \BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_live_update');
     $objTemplate->updateClass = 'tl_confirm';
     $objTemplate->updateHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdate'];
     $objTemplate->isActive = $this->isActive();
     $strMessage = ' <a href="contao/changelog.php" onclick="Backend.openModalIframe({\'width\':860,\'title\':\'CHANGELOG\',\'url\':this.href});return false" title="' . specialchars($GLOBALS['TL_LANG']['tl_maintenance']['changelog']) . '"><img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/changelog.gif" width="14" height="14" alt="" style="vertical-align:text-bottom;padding-left:3px"></a>';
     // Newer version available
     if (\Config::get('latestVersion') && version_compare(VERSION . '.' . BUILD, \Config::get('latestVersion'), '<')) {
         $objTemplate->updateClass = 'tl_info';
         $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['newVersion'], \Config::get('latestVersion')) . $strMessage;
     } else {
         $objTemplate->updateClass = 'tl_confirm';
         $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['upToDate'], VERSION . '.' . BUILD) . $strMessage;
     }
     // Automatically switch to SSL
     if (\Environment::get('ssl')) {
         \Config::set('liveUpdateBase', str_replace('http://', 'https://', \Config::get('liveUpdateBase')));
     }
     $objTemplate->uid = \Config::get('liveUpdateId');
     $objTemplate->updateServer = \Config::get('liveUpdateBase') . 'index.php';
     // Run the update
     if (\Input::get('token') != '') {
         $this->runLiveUpdate($objTemplate);
     }
     $objTemplate->version = VERSION . '.' . BUILD;
     $objTemplate->liveUpdateId = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdateId'];
     $objTemplate->runLiveUpdate = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['runLiveUpdate']);
     $objTemplate->referer = base64_encode(\Environment::get('base') . \Environment::get('request') . '|' . \Environment::get('server'));
     $objTemplate->updateHelp = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['updateHelp'], '<a href="http://luid.inetrobots.com" target="_blank">Live Update ID</a>');
     $objTemplate->phar = file_exists(TL_ROOT . '/contao/update.phar.php');
     $objTemplate->toLiveUpdate = $GLOBALS['TL_LANG']['tl_maintenance']['toLiveUpdate'];
     return $objTemplate->parse();
 }
Exemplo n.º 29
0
Arquivo: file.php Projeto: rikaix/core
 /**
  * Run the controller and parse the template
  */
 public function run()
 {
     $this->Template = new BackendTemplate('be_picker');
     $this->Template->main = '';
     // Ajax request
     if ($_POST && Environment::get('isAjaxRequest')) {
         $this->objAjax = new Ajax(Input::post('action'));
         $this->objAjax->executePreActions();
     }
     $strTable = Input::get('table');
     $strField = Input::get('field');
     $this->loadDataContainer($strTable);
     $objDca = new DC_Table($strTable);
     // AJAX request
     if ($_POST && Environment::get('isAjaxRequest')) {
         $this->objAjax->executePostActions($objDca);
     }
     $objFileTree = new $GLOBALS['BE_FFL']['fileSelector'](array('strId' => $strField, 'strTable' => $strTable, 'strField' => $strField, 'strName' => $strField, 'varValue' => explode(',', Input::get('value'))), $objDca);
     $this->Template->main = $objFileTree->generate();
     $this->Template->theme = $this->getTheme();
     $this->Template->base = Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['filepicker']);
     $this->Template->headline = $GLOBALS['TL_LANG']['MSC']['ppHeadline'];
     $this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
     $this->Template->options = $this->createPageList();
     $this->Template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode'];
     $this->Template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode'];
     $this->Template->loadingData = $GLOBALS['TL_LANG']['MSC']['loadingData'];
     $this->Template->search = $GLOBALS['TL_LANG']['MSC']['search'];
     $this->Template->action = ampersand(Environment::get('request'));
     $this->Template->value = $this->Session->get('file_selector_search');
     $GLOBALS['TL_CONFIG']['debugMode'] = false;
     $this->Template->output();
 }
Exemplo n.º 30
-1
 /**
  * Constructs a Drush alias for an environment. Used to supply
  *   organizational Drush aliases not provided by the API.
  *
  * @param Environment $environment Environment to create an alias for
  * @return string
  * @throws TerminusException
  */
 private function constructAlias($environment)
 {
     $site_name = $environment->site->get('name');
     $site_id = $environment->site->get('id');
     $env_id = $environment->get('id');
     $db_bindings = $environment->bindings->getByType('dbserver');
     $hostnames = array_keys((array) $environment->getHostnames());
     if (empty($hostnames) || empty($db_bindings)) {
         throw new TerminusException('No hostname entry for {site}.{env}', ['site' => $site_name, 'env' => $env_id], 1);
     }
     $db_binding = array_shift($db_bindings);
     $uri = array_shift($hostnames);
     $db_pass = $db_binding->get('password');
     $db_port = $db_binding->get('port');
     if (strpos(TERMINUS_HOST, 'onebox') !== false) {
         $remote_user = "******";
         $remote_host = TERMINUS_HOST;
         $db_url = "mysql://*****:*****@{$remote_host}:{$db_port}";
         $db_url .= '/pantheon';
     } else {
         $remote_user = "******";
         $remote_host = "appserver.{$env_id}.{$site_id}.drush.in";
         $db_url = "mysql://*****:*****@dbserver.{$environment}.{$site_id}";
         $db_url .= ".drush.in:{$db_port}/pantheon";
     }
     $output = "array(\n    'uri'              => {$uri},\n    'db-url'           => {$db_url},\n    'db-allows-remote' => true,\n    'remote-host'      => {$remote_host},\n    'remote-user'      => {$remote_user},\n    'ssh-options'      => '-p 2222 -o \"AddressFamily inet\"',\n    'path-aliases'     => array(\n      '%files'        => 'code/sites/default/files',\n      '%drush-script' => 'drush',\n    ),\n  );";
     return $output;
 }