silverstripe /
cwp
| 1 | <?php |
||
| 2 | |||
| 3 | namespace CWP\CWP\Extension; |
||
| 4 | |||
| 5 | use BringYourOwnIdeas\Maintenance\Reports\SiteSummary; |
||
|
0 ignored issues
–
show
|
|||
| 6 | use SilverStripe\Core\Environment; |
||
| 7 | use SilverStripe\Core\Extension; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Used to configure proxy settings for bringyourownideas/silverstripe-maintenance and its related modules |
||
| 11 | * |
||
| 12 | * @see https://www.cwp.govt.nz/developer-docs/en/2/how_tos/external_http_requests_with_proxy |
||
| 13 | */ |
||
| 14 | class MaintenanceProxyExtension extends Extension |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Configures required environment settings for Composer's use, applies to |
||
| 18 | * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in |
||
| 19 | * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer |
||
| 20 | * is created |
||
| 21 | */ |
||
| 22 | public function onAfterBuild() |
||
| 23 | { |
||
| 24 | // Provide access for Composer's StreamContextFactory, since it creates its own stream context |
||
| 25 | if ($proxy = $this->getCwpProxy()) { |
||
| 26 | $_SERVER['CGI_HTTP_PROXY'] = $proxy; |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in |
||
| 32 | * their Guzzle clients |
||
| 33 | * |
||
| 34 | * @param array $options |
||
| 35 | */ |
||
| 36 | public function updateClientOptions(&$options) |
||
| 37 | { |
||
| 38 | if ($proxy = $this->getCwpProxy()) { |
||
| 39 | $options['proxy'] = $proxy; |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234` |
||
| 45 | * |
||
| 46 | * @return string |
||
| 47 | */ |
||
| 48 | protected function getCwpProxy() |
||
| 49 | { |
||
| 50 | if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) { |
||
| 51 | return ''; |
||
| 52 | } |
||
| 53 | |||
| 54 | return sprintf( |
||
| 55 | 'tcp://%s:%d', |
||
| 56 | Environment::getEnv('SS_OUTBOUND_PROXY'), |
||
| 57 | Environment::getEnv('SS_OUTBOUND_PROXY_PORT') |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths