From dc44630f45cd6443f10749828a8a222a7737c327 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Tue, 10 Sep 2024 14:50:08 +1200 Subject: [PATCH] API Deprecate API that will be removed --- src/Task/RealMeSetupTask.php | 46 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Task/RealMeSetupTask.php b/src/Task/RealMeSetupTask.php index 7897da5..04159d6 100644 --- a/src/Task/RealMeSetupTask.php +++ b/src/Task/RealMeSetupTask.php @@ -11,6 +11,7 @@ use SilverStripe\Control\Director; use SilverStripe\Control\Controller; use SilverStripe\Dev\BuildTask; +use SilverStripe\Dev\Deprecation; /** * Class RealMeSetupTask @@ -71,14 +72,16 @@ public function run($request) $this->outputMetadataXmlContent($forEnv); - $this->message(PHP_EOL . _t( - RealMeSetupTask::class . '.BUILD_FINISH', - 'RealMe setup complete. Please copy the XML into a file for upload to the {env} environment or DIA ' . - 'to complete the integration', - array('env' => $forEnv) - )); + Deprecation::withNoReplacement(function () use ($forEnv) { + $this->message(PHP_EOL . _t( + RealMeSetupTask::class . '.BUILD_FINISH', + 'RealMe setup complete. Please copy the XML into a file for upload to the {env} environment or ' . + 'DIA to complete the integration', + array('env' => $forEnv) + )); + }); } catch (Exception $e) { - $this->message($e->getMessage() . PHP_EOL); + Deprecation::withNoReplacement(fn() => $this->message($e->getMessage() . PHP_EOL)); } } @@ -135,10 +138,13 @@ private function validateInputs($forEnv) )); } - $this->message(_t( - RealMeSetupTask::class . '.VALIDATION_SUCCESS', - 'Validation succeeded, continuing with setup...' - )); + + Deprecation::withNoReplacement(function () { + $this->message(_t( + RealMeSetupTask::class . '.VALIDATION_SUCCESS', + 'Validation succeeded, continuing with setup...' + )); + }); } /** @@ -149,12 +155,14 @@ private function validateInputs($forEnv) private function outputMetadataXmlContent($forEnv) { // Output metadata XML so that it can be sent to RealMe via the agency - $this->message(_t( - RealMeSetupTask::class . '.OUPUT_PREFIX', - 'Metadata XML is listed below for the \'{env}\' RealMe environment, this should be sent to the agency so ' . - 'they can pass it on to RealMe Operations staff', - ['env' => $forEnv] - ) . PHP_EOL . PHP_EOL); + Deprecation::withNoReplacement(function () use ($forEnv) { + $this->message(_t( + RealMeSetupTask::class . '.OUPUT_PREFIX', + 'Metadata XML is listed below for the \'{env}\' RealMe environment, this should be sent to the ' . + 'agency so they can pass it on to RealMe Operations staff', + ['env' => $forEnv] + ) . PHP_EOL . PHP_EOL); + }); $configDir = $this->getConfigurationTemplateDir(); $templateFile = Controller::join_links($configDir, 'metadata.xml'); @@ -181,7 +189,7 @@ private function outputMetadataXmlContent($forEnv) ) ); - $this->message($message); + Deprecation::withNoReplacement(fn() => $this->message($message)); } /** @@ -227,9 +235,11 @@ private function getConfigurationTemplateDir() * Output a message to the console * @param string $message * @return void + * @deprecated 5.5.0 Will be replaced with new $output parameter in the run() method */ private function message($message) { + Deprecation::notice('5.5.0', 'Will be replaced with new $output parameter in the run() method'); echo $message . PHP_EOL; }