@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use SilverStripe\Core\Extension; |
| 8 | 8 | |
| 9 | 9 | if (!class_exists(SiteSummary::class)) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -17,53 +17,53 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | class MaintenanceProxyExtension extends Extension |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Configures required environment settings for Composer's use, applies to |
|
| 22 | - * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in |
|
| 23 | - * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer |
|
| 24 | - * is created |
|
| 25 | - */ |
|
| 26 | - public function onAfterBuild() |
|
| 27 | - { |
|
| 28 | - // Mock COMPOSER_HOME if it's not defined already. Composer requires one of the two to be set. |
|
| 29 | - if (!Environment::getEnv('HOME') && !Environment::getEnv('COMPOSER_HOME')) { |
|
| 30 | - putenv('COMPOSER_HOME=/tmp'); |
|
| 31 | - } |
|
| 20 | + /** |
|
| 21 | + * Configures required environment settings for Composer's use, applies to |
|
| 22 | + * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in |
|
| 23 | + * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer |
|
| 24 | + * is created |
|
| 25 | + */ |
|
| 26 | + public function onAfterBuild() |
|
| 27 | + { |
|
| 28 | + // Mock COMPOSER_HOME if it's not defined already. Composer requires one of the two to be set. |
|
| 29 | + if (!Environment::getEnv('HOME') && !Environment::getEnv('COMPOSER_HOME')) { |
|
| 30 | + putenv('COMPOSER_HOME=/tmp'); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - // Provide access for Composer's StreamContextFactory, since it creates its own stream context |
|
| 34 | - if ($proxy = $this->getCwpProxy()) { |
|
| 35 | - $_SERVER['CGI_HTTP_PROXY'] = $proxy; |
|
| 36 | - } |
|
| 37 | - } |
|
| 33 | + // Provide access for Composer's StreamContextFactory, since it creates its own stream context |
|
| 34 | + if ($proxy = $this->getCwpProxy()) { |
|
| 35 | + $_SERVER['CGI_HTTP_PROXY'] = $proxy; |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in |
|
| 41 | - * their Guzzle clients |
|
| 42 | - * |
|
| 43 | - * @param array $options |
|
| 44 | - */ |
|
| 45 | - public function updateClientOptions(&$options) |
|
| 46 | - { |
|
| 47 | - if ($proxy = $this->getCwpProxy()) { |
|
| 48 | - $options['proxy'] = $proxy; |
|
| 49 | - } |
|
| 50 | - } |
|
| 39 | + /** |
|
| 40 | + * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in |
|
| 41 | + * their Guzzle clients |
|
| 42 | + * |
|
| 43 | + * @param array $options |
|
| 44 | + */ |
|
| 45 | + public function updateClientOptions(&$options) |
|
| 46 | + { |
|
| 47 | + if ($proxy = $this->getCwpProxy()) { |
|
| 48 | + $options['proxy'] = $proxy; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234` |
|
| 54 | - * |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - protected function getCwpProxy() |
|
| 58 | - { |
|
| 59 | - if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 52 | + /** |
|
| 53 | + * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234` |
|
| 54 | + * |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + protected function getCwpProxy() |
|
| 58 | + { |
|
| 59 | + if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return sprintf( |
|
| 64 | - 'tcp://%s:%d', |
|
| 65 | - Environment::getEnv('SS_OUTBOUND_PROXY'), |
|
| 66 | - Environment::getEnv('SS_OUTBOUND_PROXY_PORT') |
|
| 67 | - ); |
|
| 68 | - } |
|
| 63 | + return sprintf( |
|
| 64 | + 'tcp://%s:%d', |
|
| 65 | + Environment::getEnv('SS_OUTBOUND_PROXY'), |
|
| 66 | + Environment::getEnv('SS_OUTBOUND_PROXY_PORT') |
|
| 67 | + ); |
|
| 68 | + } |
|
| 69 | 69 | } |