From 51fcc4dea2db8ca4f082262a44259f6f010dc536 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 18 Oct 2024 10:20:13 +1300 Subject: [PATCH] ENH Do not emit deprecation notices for supported modules by default --- src/Transformer/YamlTransformer.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Transformer/YamlTransformer.php b/src/Transformer/YamlTransformer.php index 958e63f..30dad2f 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,9 @@ private function checkForDeprecatedConfig(array $document, MutableConfigCollecti if (!($collection instanceof MemoryConfigCollection)) { return; } + if ($document['inSupportedModule'] && !Deprecation::getShowNoticesCalledFromSupportedCode()) { + return; + } foreach ($document['content'] as $key => $value) { if (!is_array($value)) { continue; @@ -240,8 +244,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, ];