From be1e82a6d1f6bc71de87f83c9fb60ca48cdff569 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Mon, 21 Oct 2024 10:14:57 +1300 Subject: [PATCH] ENH Do not emit deprecation notices for supported modules by default --- src/Transformer/YamlTransformer.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Transformer/YamlTransformer.php b/src/Transformer/YamlTransformer.php index 958e63f..aa24f6e 100644 --- a/src/Transformer/YamlTransformer.php +++ b/src/Transformer/YamlTransformer.php @@ -10,6 +10,7 @@ use Exception; use Closure; use SilverStripe\Config\Collections\MemoryConfigCollection; +use SilverStripe\Dev\Deprecation; class YamlTransformer implements TransformerInterface { @@ -135,6 +136,15 @@ private function checkForDeprecatedConfig(array $document, MutableConfigCollecti if (!($collection instanceof MemoryConfigCollection)) { return; } + $showNoticesCalledFromSupportedCode = false; + if (class_exists(Deprecation::class) + && method_exists(Deprecation::class, 'getShowNoticesCalledFromSupportedCode') + ) { + $showNoticesCalledFromSupportedCode = Deprecation::getShowNoticesCalledFromSupportedCode(); + } + if ($document['inSupportedModule'] && !$showNoticesCalledFromSupportedCode) { + return; + } foreach ($document['content'] as $key => $value) { if (!is_array($value)) { continue; @@ -240,8 +250,14 @@ protected function getNamedYamlDocuments() ); } + $inSupportedModule = false; + if (class_exists(Deprecation::class) && method_exists(Deprecation::class, 'fileIsInSupportedModule')) { + $inSupportedModule = Deprecation::fileIsInSupportedModule($document['filename']); + } + $filename = $document['filename']; $documents[$header['name']] = [ - 'filename' => $document['filename'], + 'filename' => $filename, + 'inSupportedModule' => $inSupportedModule, 'header' => $header, 'content' => $content, ];