|
3 | 3 | namespace Becklyn\AssetsBundle\DependencyInjection; |
4 | 4 |
|
5 | 5 | use Becklyn\AssetsBundle\Asset\Asset; |
| 6 | +use Symfony\Component\Config\Definition\BaseNode; |
6 | 7 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
7 | 8 | use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
8 | 9 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
@@ -34,7 +35,7 @@ public function getConfigTreeBuilder () |
34 | 35 | ->defaultFalse() |
35 | 36 | ->end() |
36 | 37 | ->arrayNode("dependency_maps") |
37 | | - ->setDeprecated("The `becklyn_assets.dependency_maps` option is deprecated, as the the maps will always be automatically loaded.") |
| 38 | + ->setDeprecated(...$this->formatDeprecationMessage("becklyn/assets-bundle", "2.6.6", "The %path%.%node% option is deprecated, as the the maps will always be automatically loaded.")) |
38 | 39 | ->scalarPrototype()->end() |
39 | 40 | ->defaultValue([]) |
40 | 41 | ->info("The paths to the dependency maps. In asset notation: e.g. `@namespace/js/_dependencies.json`") |
@@ -96,4 +97,19 @@ function (array $paths) |
96 | 97 | ->info($description) |
97 | 98 | ->defaultValue([]); |
98 | 99 | } |
| 100 | + |
| 101 | + /** |
| 102 | + * Returns the correct deprecation param's as an array for setDeprecated. |
| 103 | + * |
| 104 | + * Symfony/Config v5.1 introduces a deprecation notice when calling |
| 105 | + * setDeprecation() with less than 3 args and the getDeprecation method was |
| 106 | + * introduced at the same time. By checking if getDeprecation() exists, |
| 107 | + * we can determine the correct param count to use when calling setDeprecated. |
| 108 | + */ |
| 109 | + private function formatDeprecationMessage (string $bundle, string $version, string $message) : array |
| 110 | + { |
| 111 | + return \method_exists(BaseNode::class, 'getDeprecation') |
| 112 | + ? [$bundle, $version, $message] |
| 113 | + : [$message]; |
| 114 | + } |
99 | 115 | } |
0 commit comments