|
5 | 5 | namespace Doctrine\Bundle\MigrationsBundle\DependencyInjection;
|
6 | 6 |
|
7 | 7 | use ReflectionClass;
|
| 8 | +use Symfony\Component\Config\Definition\BaseNode; |
8 | 9 | use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
9 | 10 | use Symfony\Component\Config\Definition\ConfigurationInterface;
|
10 | 11 | use function constant;
|
@@ -43,7 +44,7 @@ public function getConfigTreeBuilder() : TreeBuilder
|
43 | 44 | $rootNode
|
44 | 45 | ->children()
|
45 | 46 | ->scalarNode('name')
|
46 |
| - ->setDeprecated('The "%node%" option is deprecated.') |
| 47 | + ->setDeprecated(...$this->getDeprecationParams('The "%node%" option is deprecated.')) |
47 | 48 | ->defaultValue('Application Migrations')
|
48 | 49 | ->end()
|
49 | 50 |
|
@@ -91,27 +92,27 @@ public function getConfigTreeBuilder() : TreeBuilder
|
91 | 92 |
|
92 | 93 | ->scalarNode('dir_name')
|
93 | 94 | ->defaultValue('%kernel.root_dir%/DoctrineMigrations')->cannotBeEmpty()
|
94 |
| - ->setDeprecated('The "%node%" option is deprecated. Use "migrations_paths" instead.') |
| 95 | + ->setDeprecated(...$this->getDeprecationParams('The "%node%" option is deprecated. Use "migrations_paths" instead.')) |
95 | 96 | ->end()
|
96 | 97 | ->scalarNode('namespace')
|
97 | 98 | ->defaultValue('Application\Migrations')->cannotBeEmpty()
|
98 |
| - ->setDeprecated('The "%node%" option is deprecated. Use "migrations_paths" instead.') |
| 99 | + ->setDeprecated(...$this->getDeprecationParams('The "%node%" option is deprecated. Use "migrations_paths" instead.')) |
99 | 100 | ->end()
|
100 | 101 | ->scalarNode('table_name')
|
101 | 102 | ->defaultValue('migration_versions')->cannotBeEmpty()
|
102 |
| - ->setDeprecated('The "%node%" option is deprecated. Use "storage.table_storage.table_name" instead.') |
| 103 | + ->setDeprecated(...$this->getDeprecationParams('The "%node%" option is deprecated. Use "storage.table_storage.table_name" instead.')) |
103 | 104 | ->end()
|
104 | 105 | ->scalarNode('column_name')
|
105 | 106 | ->defaultValue('version')
|
106 |
| - ->setDeprecated('The "%node%" option is deprecated. Use "storage.table_storage.version_column_name" instead.') |
| 107 | + ->setDeprecated(...$this->getDeprecationParams('The "%node%" option is deprecated. Use "storage.table_storage.version_column_name" instead.')) |
107 | 108 | ->end()
|
108 | 109 | ->scalarNode('column_length')
|
109 | 110 | ->defaultValue(14)
|
110 |
| - ->setDeprecated('The "%node%" option is deprecated. Use "storage.table_storage.version_column_length" instead.') |
| 111 | + ->setDeprecated(...$this->getDeprecationParams('The "%node%" option is deprecated. Use "storage.table_storage.version_column_length" instead.')) |
111 | 112 | ->end()
|
112 | 113 | ->scalarNode('executed_at_column_name')
|
113 | 114 | ->defaultValue('executed_at')
|
114 |
| - ->setDeprecated('The "%node%" option is deprecated. Use "storage.table_storage.executed_at_column_name" instead.') |
| 115 | + ->setDeprecated(...$this->getDeprecationParams('The "%node%" option is deprecated. Use "storage.table_storage.executed_at_column_name" instead.')) |
115 | 116 | ->end()
|
116 | 117 | ->scalarNode('all_or_nothing')->defaultValue(false)->end()
|
117 | 118 | ->scalarNode('custom_template')->defaultValue(null)->end()
|
@@ -167,4 +168,27 @@ private function getOrganizeMigrationsModes() : array
|
167 | 168 |
|
168 | 169 | return $namesArray;
|
169 | 170 | }
|
| 171 | + |
| 172 | + /** |
| 173 | + * Returns the correct deprecation params as an array for setDeprecated(). |
| 174 | + * |
| 175 | + * symfony/config v5.1 introduces a deprecation notice when calling |
| 176 | + * setDeprecated() with less than 3 args and the getDeprecation() method was |
| 177 | + * introduced at the same time. By checking if getDeprecation() exists, |
| 178 | + * we can determine the correct param count to use when calling setDeprecated(). |
| 179 | + * |
| 180 | + * @return string[] |
| 181 | + */ |
| 182 | + private function getDeprecationParams(string $message) : array |
| 183 | + { |
| 184 | + if (method_exists(BaseNode::class, 'getDeprecation')) { |
| 185 | + return [ |
| 186 | + 'doctrine/doctrine-migrations-bundle', |
| 187 | + '2.2', |
| 188 | + $message, |
| 189 | + ]; |
| 190 | + } |
| 191 | + |
| 192 | + return [$message]; |
| 193 | + } |
170 | 194 | }
|
0 commit comments