From cd93a1535b761cd44b83940bfa4f26fc1e791ce5 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 17 Oct 2024 15:29:00 +1300 Subject: [PATCH] ENH Do not emit deprecation notices for supported modules by default --- composer.json | 3 ++- src/Transformer/YamlTransformer.php | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e2e716c..58aa48f 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "symfony/finder": "^6.1", "symfony/yaml": "^6.1", "marcj/topsort": "^2.0.0", - "psr/simple-cache": "^3.0.0" + "psr/simple-cache": "^3.0.0", + "silverstripe/framework": "^5.4.0" }, "require-dev": { "phpunit/phpunit": "^9.6", diff --git a/src/Transformer/YamlTransformer.php b/src/Transformer/YamlTransformer.php index 958e63f..6a852e6 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,10 @@ protected function getNamedYamlDocuments() ); } + $filename = $document['filename']; $documents[$header['name']] = [ - 'filename' => $document['filename'], + 'filename' => $filename, + 'inSupportedModule' => Deprecation::fileIsInSupportedModule($filename), 'header' => $header, 'content' => $content, ];