Skip to content

Commit

Permalink
Update MaintenanceProxyExtension for use in CWP 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Jun 26, 2018
1 parent 837920a commit f27f2a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion _config/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Name: maintenanceproxyextensions
Before: updatecheckerextensions
Only:
moduleexists: bringyourownideas/silverstripe-maintenance
moduleexists: silverstripe-maintenance
---
BringYourOwnIdeas\Maintenance\Util\ComposerLoader:
extensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

namespace CWP\CWP\Extension;

use BringYourOwnIdeas\Maintenance\Reports\SiteSummary;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Extension;

if (!class_exists(SiteSummary::class)) {
return;
}
use Extension;

/**
* Used to configure proxy settings for bringyourownideas/silverstripe-maintenance and its related modules
Expand All @@ -25,11 +19,6 @@ class MaintenanceProxyExtension extends Extension
*/
public function onAfterBuild()
{
// Mock COMPOSER_HOME if it's not defined already. Composer requires one of the two to be set.
if (!Environment::getEnv('HOME') && !Environment::getEnv('COMPOSER_HOME')) {
putenv('COMPOSER_HOME=/tmp');
}

// Provide access for Composer's StreamContextFactory, since it creates its own stream context
if ($proxy = $this->getCwpProxy()) {
$_SERVER['CGI_HTTP_PROXY'] = $proxy;
Expand All @@ -56,14 +45,14 @@ public function updateClientOptions(&$options)
*/
protected function getCwpProxy()
{
if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) {
if (!defined('SS_OUTBOUND_PROXY') || !defined('SS_OUTBOUND_PROXY_PORT')) {
return '';
}

return sprintf(
'tcp://%s:%d',
Environment::getEnv('SS_OUTBOUND_PROXY'),
Environment::getEnv('SS_OUTBOUND_PROXY_PORT')
SS_OUTBOUND_PROXY,
SS_OUTBOUND_PROXY_PORT
);
}
}

0 comments on commit f27f2a7

Please sign in to comment.