@@ -250,22 +250,22 @@ |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | - * Returns the native language name for the selected locale/language, empty string if Translatable is not available |
|
| 254 | - * |
|
| 255 | - * @return string |
|
| 256 | - */ |
|
| 257 | - public function getSelectedLanguage() |
|
| 258 | - { |
|
| 259 | - if (!class_exists('Translatable')) { |
|
| 260 | - return ''; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - $language = explode('_', Translatable::get_current_locale()); |
|
| 264 | - $languageCode = array_shift($language); |
|
| 265 | - $nativeName = i18n::get_language_name($languageCode, true); |
|
| 266 | - |
|
| 267 | - return $nativeName; |
|
| 268 | - } |
|
| 253 | + * Returns the native language name for the selected locale/language, empty string if Translatable is not available |
|
| 254 | + * |
|
| 255 | + * @return string |
|
| 256 | + */ |
|
| 257 | + public function getSelectedLanguage() |
|
| 258 | + { |
|
| 259 | + if (!class_exists('Translatable')) { |
|
| 260 | + return ''; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + $language = explode('_', Translatable::get_current_locale()); |
|
| 264 | + $languageCode = array_shift($language); |
|
| 265 | + $nativeName = i18n::get_language_name($languageCode, true); |
|
| 266 | + |
|
| 267 | + return $nativeName; |
|
| 268 | + } |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | class BasePage_Controller extends ContentController { |
@@ -66,7 +66,9 @@ discard block |
||
| 66 | 66 | $baseName = sprintf('%s-%s', $this->URLSegment, $this->ID); |
| 67 | 67 | |
| 68 | 68 | $folderPath = Config::inst()->get('BasePage', 'generated_pdf_path'); |
| 69 | - if($folderPath[0] != '/') $folderPath = BASE_PATH . '/' . $folderPath; |
|
| 69 | + if($folderPath[0] != '/') { |
|
| 70 | + $folderPath = BASE_PATH . '/' . $folderPath; |
|
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | return sprintf('%s/%s.pdf', $folderPath, $baseName); |
| 72 | 74 | } |
@@ -75,7 +77,9 @@ discard block |
||
| 75 | 77 | * Build pdf link for template. |
| 76 | 78 | */ |
| 77 | 79 | public function PdfLink() { |
| 78 | - if(!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
| 80 | + if(!Config::inst()->get('BasePage', 'pdf_export')) { |
|
| 81 | + return false; |
|
| 82 | + } |
|
| 79 | 83 | |
| 80 | 84 | $path = $this->getPdfFilename(); |
| 81 | 85 | |
@@ -112,7 +116,9 @@ discard block |
||
| 112 | 116 | * @return boolean |
| 113 | 117 | */ |
| 114 | 118 | public function doUnpublish() { |
| 115 | - if(!parent::doUnpublish()) return false; |
|
| 119 | + if(!parent::doUnpublish()) { |
|
| 120 | + return false; |
|
| 121 | + } |
|
| 116 | 122 | |
| 117 | 123 | $filepath = $this->getPdfFilename(); |
| 118 | 124 | if(file_exists($filepath)) { |
@@ -245,8 +251,11 @@ discard block |
||
| 245 | 251 | ))); |
| 246 | 252 | } |
| 247 | 253 | |
| 248 | - if ($translations->count()>1) return $translations; |
|
| 249 | - else return null; |
|
| 254 | + if ($translations->count()>1) { |
|
| 255 | + return $translations; |
|
| 256 | + } else { |
|
| 257 | + return null; |
|
| 258 | + } |
|
| 250 | 259 | } |
| 251 | 260 | |
| 252 | 261 | /** |
@@ -308,7 +317,9 @@ discard block |
||
| 308 | 317 | * Serve the page rendered as PDF. |
| 309 | 318 | */ |
| 310 | 319 | public function downloadpdf() { |
| 311 | - if(!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
| 320 | + if(!Config::inst()->get('BasePage', 'pdf_export')) { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 312 | 323 | |
| 313 | 324 | // We only allow producing live pdf. There is no way to secure the draft files. |
| 314 | 325 | Versioned::reading_stage('Live'); |
@@ -356,7 +367,9 @@ discard block |
||
| 356 | 367 | * Render the page as PDF using wkhtmltopdf. |
| 357 | 368 | */ |
| 358 | 369 | public function generatePDF() { |
| 359 | - if(!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
| 370 | + if(!Config::inst()->get('BasePage', 'pdf_export')) { |
|
| 371 | + return false; |
|
| 372 | + } |
|
| 360 | 373 | |
| 361 | 374 | $binaryPath = Config::inst()->get('BasePage', 'wkhtmltopdf_binary'); |
| 362 | 375 | if(!$binaryPath || !is_executable($binaryPath)) { |
@@ -381,7 +394,9 @@ discard block |
||
| 381 | 394 | $footerFile = str_replace('.pdf', '_pdffooter.html', $pdfFile); |
| 382 | 395 | |
| 383 | 396 | // make sure the work directory exists |
| 384 | - if(!file_exists(dirname($pdfFile))) Filesystem::makeFolder(dirname($pdfFile)); |
|
| 397 | + if(!file_exists(dirname($pdfFile))) { |
|
| 398 | + Filesystem::makeFolder(dirname($pdfFile)); |
|
| 399 | + } |
|
| 385 | 400 | |
| 386 | 401 | //decide the domain to use in generation |
| 387 | 402 | $pdf_base_url = $this->getPDFBaseURL(); |
@@ -313,13 +313,25 @@ discard block |
||
| 313 | 313 | $year = $this->request->getVar('year'); |
| 314 | 314 | $month = $this->request->getVar('month'); |
| 315 | 315 | |
| 316 | - if ($tag=='') $tag = null; |
|
| 317 | - if ($from=='') $from = null; |
|
| 318 | - if ($to=='') $to = null; |
|
| 319 | - if ($year=='') $year = null; |
|
| 320 | - if ($month=='') $month = null; |
|
| 316 | + if ($tag=='') { |
|
| 317 | + $tag = null; |
|
| 318 | + } |
|
| 319 | + if ($from=='') { |
|
| 320 | + $from = null; |
|
| 321 | + } |
|
| 322 | + if ($to=='') { |
|
| 323 | + $to = null; |
|
| 324 | + } |
|
| 325 | + if ($year=='') { |
|
| 326 | + $year = null; |
|
| 327 | + } |
|
| 328 | + if ($month=='') { |
|
| 329 | + $month = null; |
|
| 330 | + } |
|
| 321 | 331 | |
| 322 | - if (isset($tag)) $tag = (int)$tag; |
|
| 332 | + if (isset($tag)) { |
|
| 333 | + $tag = (int)$tag; |
|
| 334 | + } |
|
| 323 | 335 | if (isset($from)) { |
| 324 | 336 | $from = urldecode($from); |
| 325 | 337 | $parser = new SS_Datetime; |
@@ -332,8 +344,12 @@ discard block |
||
| 332 | 344 | $parser->setValue($to); |
| 333 | 345 | $to = $parser->Format('Y-m-d'); |
| 334 | 346 | } |
| 335 | - if (isset($year)) $year = (int)$year; |
|
| 336 | - if (isset($month)) $month = (int)$month; |
|
| 347 | + if (isset($year)) { |
|
| 348 | + $year = (int)$year; |
|
| 349 | + } |
|
| 350 | + if (isset($month)) { |
|
| 351 | + $month = (int)$month; |
|
| 352 | + } |
|
| 337 | 353 | |
| 338 | 354 | // If only "To" has been provided filter by single date. Normalise by swapping with "From". |
| 339 | 355 | if (isset($to) && !isset($from)) { |
@@ -499,7 +515,9 @@ discard block |
||
| 499 | 515 | // Build the link - keep the tag, but reset month, year and pagination. |
| 500 | 516 | $link = HTTP::setGetVar('from', $params['from'], $this->AbsoluteLink(), '&'); |
| 501 | 517 | $link = HTTP::setGetVar('to', $params['to'], $link, '&'); |
| 502 | - if (isset($params['tag'])) $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
| 518 | + if (isset($params['tag'])) { |
|
| 519 | + $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
| 520 | + } |
|
| 503 | 521 | |
| 504 | 522 | $this->redirect($link); |
| 505 | 523 | } |
@@ -509,7 +527,9 @@ discard block |
||
| 509 | 527 | |
| 510 | 528 | // Reset the link - only include the tag. |
| 511 | 529 | $link = $this->AbsoluteLink(); |
| 512 | - if (isset($params['tag'])) $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
| 530 | + if (isset($params['tag'])) { |
|
| 531 | + $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
| 532 | + } |
|
| 513 | 533 | |
| 514 | 534 | $this->redirect($link); |
| 515 | 535 | } |
@@ -17,7 +17,9 @@ |
||
| 17 | 17 | if(Config::inst()->get('CwpWorkflowDefinitionExtension', 'create_default_workflow')) { |
| 18 | 18 | // Only proceed if a definition using this template has not been created yet |
| 19 | 19 | $definition = WorkflowDefinition::get()->filter("Template", "Review and Approve")->First(); |
| 20 | - if($definition && $definition->exists()) return; |
|
| 20 | + if($definition && $definition->exists()) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 21 | 23 | |
| 22 | 24 | //generate from the template, which happens after we write the definition |
| 23 | 25 | $definition = WorkflowDefinition::create(); |
@@ -1,80 +1,80 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class BasePageTest extends SapphireTest |
| 3 | 3 | { |
| 4 | - public static $fixture_file = 'BasePageTest.yml'; |
|
| 4 | + public static $fixture_file = 'BasePageTest.yml'; |
|
| 5 | 5 | |
| 6 | - public function setUp() |
|
| 7 | - { |
|
| 8 | - parent::setUp(); |
|
| 6 | + public function setUp() |
|
| 7 | + { |
|
| 8 | + parent::setUp(); |
|
| 9 | 9 | |
| 10 | - Config::nest(); |
|
| 11 | - Config::inst()->update('BasePage', 'pdf_export', true); |
|
| 12 | - Config::inst()->update('BasePage', 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
| 13 | - } |
|
| 10 | + Config::nest(); |
|
| 11 | + Config::inst()->update('BasePage', 'pdf_export', true); |
|
| 12 | + Config::inst()->update('BasePage', 'generated_pdf_path', 'assets/_generated_pdfs'); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function testPdfFilename() |
|
| 16 | - { |
|
| 17 | - $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 18 | - $this->assertContains( |
|
| 19 | - 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
| 20 | - $page->getPdfFilename(), |
|
| 21 | - 'Generated filename for PDF' |
|
| 22 | - ); |
|
| 23 | - } |
|
| 15 | + public function testPdfFilename() |
|
| 16 | + { |
|
| 17 | + $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 18 | + $this->assertContains( |
|
| 19 | + 'assets/_generated_pdfs/test-page-one-1.pdf', |
|
| 20 | + $page->getPdfFilename(), |
|
| 21 | + 'Generated filename for PDF' |
|
| 22 | + ); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function testPdfLink() |
|
| 26 | - { |
|
| 27 | - $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 28 | - $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 29 | - } |
|
| 25 | + public function testPdfLink() |
|
| 26 | + { |
|
| 27 | + $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 28 | + $this->assertContains('test-page-one/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public function testHomePagePdfLink() |
|
| 32 | - { |
|
| 33 | - $page = $this->objFromFixture('BasePage', 'home-page'); |
|
| 34 | - $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 35 | - } |
|
| 31 | + public function testHomePagePdfLink() |
|
| 32 | + { |
|
| 33 | + $page = $this->objFromFixture('BasePage', 'home-page'); |
|
| 34 | + $this->assertContains('home/downloadpdf', $page->PdfLink(), 'Link to download PDF'); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function testPdfLinkDisabled() |
|
| 38 | - { |
|
| 39 | - Config::inst()->update('BasePage', 'pdf_export', false); |
|
| 40 | - $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 41 | - $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
| 42 | - } |
|
| 37 | + public function testPdfLinkDisabled() |
|
| 38 | + { |
|
| 39 | + Config::inst()->update('BasePage', 'pdf_export', false); |
|
| 40 | + $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 41 | + $this->assertFalse($page->PdfLink(), 'No PDF link as the functionality is disabled'); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Test that the native language name can be returned for the current locale |
|
| 46 | - * |
|
| 47 | - * @see i18n |
|
| 48 | - * @param string $locale |
|
| 49 | - * @param string $expected |
|
| 50 | - * @dataProvider localeProvider |
|
| 51 | - */ |
|
| 52 | - public function testGetSelectedLanguage($locale, $expected) |
|
| 53 | - { |
|
| 54 | - if (!class_exists('Translatable')) { |
|
| 55 | - $this->markTestSkipped('Language tests require Translatable module.'); |
|
| 56 | - } |
|
| 44 | + /** |
|
| 45 | + * Test that the native language name can be returned for the current locale |
|
| 46 | + * |
|
| 47 | + * @see i18n |
|
| 48 | + * @param string $locale |
|
| 49 | + * @param string $expected |
|
| 50 | + * @dataProvider localeProvider |
|
| 51 | + */ |
|
| 52 | + public function testGetSelectedLanguage($locale, $expected) |
|
| 53 | + { |
|
| 54 | + if (!class_exists('Translatable')) { |
|
| 55 | + $this->markTestSkipped('Language tests require Translatable module.'); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - Translatable::set_current_locale($locale); |
|
| 59 | - $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 60 | - $this->assertSame($expected, $page->getSelectedLanguage()); |
|
| 61 | - } |
|
| 58 | + Translatable::set_current_locale($locale); |
|
| 59 | + $page = $this->objFromFixture('BasePage', 'test-page-one'); |
|
| 60 | + $this->assertSame($expected, $page->getSelectedLanguage()); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @return array[] |
|
| 65 | - */ |
|
| 66 | - public function localeProvider() |
|
| 67 | - { |
|
| 68 | - return array( |
|
| 69 | - array('en_NZ', 'English'), |
|
| 70 | - array('af_ZA', 'Afrikaans'), |
|
| 71 | - array('es_ES', 'español') |
|
| 72 | - ); |
|
| 73 | - } |
|
| 63 | + /** |
|
| 64 | + * @return array[] |
|
| 65 | + */ |
|
| 66 | + public function localeProvider() |
|
| 67 | + { |
|
| 68 | + return array( |
|
| 69 | + array('en_NZ', 'English'), |
|
| 70 | + array('af_ZA', 'Afrikaans'), |
|
| 71 | + array('es_ES', 'español') |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function tearDown() |
|
| 76 | - { |
|
| 77 | - Config::unnest(); |
|
| 78 | - parent::tearDown(); |
|
| 79 | - } |
|
| 75 | + public function tearDown() |
|
| 76 | + { |
|
| 77 | + Config::unnest(); |
|
| 78 | + parent::tearDown(); |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -44,10 +44,10 @@ |
||
| 44 | 44 | $query->exclude('SiteTree_ShowInSearch', 0); |
| 45 | 45 | |
| 46 | 46 | // Add File_ShowInSearch if the File class is in the query |
| 47 | - $classes = array_column($classes, 'class'); |
|
| 48 | - if (in_array('File', $classes)) { |
|
| 49 | - $query->exclude('File_ShowInSearch', 0); |
|
| 50 | - } |
|
| 47 | + $classes = array_column($classes, 'class'); |
|
| 48 | + if (in_array('File', $classes)) { |
|
| 49 | + $query->exclude('File_ShowInSearch', 0); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | // Artificially lower the amount of results to prevent too high resource usage. |
| 53 | 53 | // on subsequent canView check loop. |
@@ -5,41 +5,41 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class CwpSiteSummaryExtension extends Extension |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Updates the modules used for the version label by: |
|
| 10 | - * - Removing SS Framework |
|
| 11 | - * - Adding CWP |
|
| 12 | - * - Relabelling SS CMS |
|
| 13 | - * |
|
| 14 | - * @param array $modules |
|
| 15 | - */ |
|
| 16 | - public function updateVersionModules(&$modules) |
|
| 17 | - { |
|
| 18 | - unset($modules['silverstripe/framework']); |
|
| 19 | - $modules = ['cwp/cwp' => 'CWP'] + $modules; |
|
| 20 | - $modules['silverstripe/cms'] = 'SilverStripe CMS'; |
|
| 21 | - } |
|
| 8 | + /** |
|
| 9 | + * Updates the modules used for the version label by: |
|
| 10 | + * - Removing SS Framework |
|
| 11 | + * - Adding CWP |
|
| 12 | + * - Relabelling SS CMS |
|
| 13 | + * |
|
| 14 | + * @param array $modules |
|
| 15 | + */ |
|
| 16 | + public function updateVersionModules(&$modules) |
|
| 17 | + { |
|
| 18 | + unset($modules['silverstripe/framework']); |
|
| 19 | + $modules = ['cwp/cwp' => 'CWP'] + $modules; |
|
| 20 | + $modules['silverstripe/cms'] = 'SilverStripe CMS'; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing |
|
| 25 | - * filter options) |
|
| 26 | - * |
|
| 27 | - * @param GridFieldDropdownFilter $dropdownFilter |
|
| 28 | - */ |
|
| 29 | - public function updateDropdownFilterOptions($dropdownFilter) |
|
| 30 | - { |
|
| 31 | - $dropdownFilter->removeFilterOption('supported'); |
|
| 32 | - $dropdownFilter->removeFilterOption('unsupported'); |
|
| 23 | + /** |
|
| 24 | + * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing |
|
| 25 | + * filter options) |
|
| 26 | + * |
|
| 27 | + * @param GridFieldDropdownFilter $dropdownFilter |
|
| 28 | + */ |
|
| 29 | + public function updateDropdownFilterOptions($dropdownFilter) |
|
| 30 | + { |
|
| 31 | + $dropdownFilter->removeFilterOption('supported'); |
|
| 32 | + $dropdownFilter->removeFilterOption('unsupported'); |
|
| 33 | 33 | |
| 34 | - $dropdownFilter->addFilterOption( |
|
| 35 | - 'supported', |
|
| 36 | - _t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'), |
|
| 37 | - ['Supported' => true] |
|
| 38 | - ); |
|
| 39 | - $dropdownFilter->addFilterOption( |
|
| 40 | - 'unsupported', |
|
| 41 | - _t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'), |
|
| 42 | - ['Supported' => false] |
|
| 43 | - ); |
|
| 44 | - } |
|
| 34 | + $dropdownFilter->addFilterOption( |
|
| 35 | + 'supported', |
|
| 36 | + _t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'), |
|
| 37 | + ['Supported' => true] |
|
| 38 | + ); |
|
| 39 | + $dropdownFilter->addFilterOption( |
|
| 40 | + 'unsupported', |
|
| 41 | + _t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'), |
|
| 42 | + ['Supported' => false] |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -11,48 +11,48 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class MaintenanceProxyExtension extends Extension |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Configures required environment settings for Composer's use, applies to |
|
| 16 | - * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in |
|
| 17 | - * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer |
|
| 18 | - * is created |
|
| 19 | - */ |
|
| 20 | - public function onAfterBuild() |
|
| 21 | - { |
|
| 22 | - // Provide access for Composer's StreamContextFactory, since it creates its own stream context |
|
| 23 | - if ($proxy = $this->getCwpProxy()) { |
|
| 24 | - $_SERVER['CGI_HTTP_PROXY'] = $proxy; |
|
| 25 | - } |
|
| 26 | - } |
|
| 14 | + /** |
|
| 15 | + * Configures required environment settings for Composer's use, applies to |
|
| 16 | + * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in |
|
| 17 | + * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer |
|
| 18 | + * is created |
|
| 19 | + */ |
|
| 20 | + public function onAfterBuild() |
|
| 21 | + { |
|
| 22 | + // Provide access for Composer's StreamContextFactory, since it creates its own stream context |
|
| 23 | + if ($proxy = $this->getCwpProxy()) { |
|
| 24 | + $_SERVER['CGI_HTTP_PROXY'] = $proxy; |
|
| 25 | + } |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in |
|
| 30 | - * their Guzzle clients |
|
| 31 | - * |
|
| 32 | - * @param array $options |
|
| 33 | - */ |
|
| 34 | - public function updateClientOptions(&$options) |
|
| 35 | - { |
|
| 36 | - if ($proxy = $this->getCwpProxy()) { |
|
| 37 | - $options['proxy'] = $proxy; |
|
| 38 | - } |
|
| 39 | - } |
|
| 28 | + /** |
|
| 29 | + * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in |
|
| 30 | + * their Guzzle clients |
|
| 31 | + * |
|
| 32 | + * @param array $options |
|
| 33 | + */ |
|
| 34 | + public function updateClientOptions(&$options) |
|
| 35 | + { |
|
| 36 | + if ($proxy = $this->getCwpProxy()) { |
|
| 37 | + $options['proxy'] = $proxy; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234` |
|
| 43 | - * |
|
| 44 | - * @return string |
|
| 45 | - */ |
|
| 46 | - protected function getCwpProxy() |
|
| 47 | - { |
|
| 48 | - if (!defined('SS_OUTBOUND_PROXY') || !defined('SS_OUTBOUND_PROXY_PORT')) { |
|
| 49 | - return ''; |
|
| 50 | - } |
|
| 41 | + /** |
|
| 42 | + * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234` |
|
| 43 | + * |
|
| 44 | + * @return string |
|
| 45 | + */ |
|
| 46 | + protected function getCwpProxy() |
|
| 47 | + { |
|
| 48 | + if (!defined('SS_OUTBOUND_PROXY') || !defined('SS_OUTBOUND_PROXY_PORT')) { |
|
| 49 | + return ''; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - return sprintf( |
|
| 53 | - 'tcp://%s:%d', |
|
| 54 | - SS_OUTBOUND_PROXY, |
|
| 55 | - SS_OUTBOUND_PROXY_PORT |
|
| 56 | - ); |
|
| 57 | - } |
|
| 52 | + return sprintf( |
|
| 53 | + 'tcp://%s:%d', |
|
| 54 | + SS_OUTBOUND_PROXY, |
|
| 55 | + SS_OUTBOUND_PROXY_PORT |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | 58 | } |