Skip to content

Commit 2fdc67e

Browse files
authored
Merge pull request #38 from vivait/feature/v3
Remove legacy v1 configuration support
2 parents d2a501c + 5ace55c commit 2fdc67e

4 files changed

Lines changed: 22 additions & 62 deletions

File tree

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ generates a new string.
99

1010
## Install
1111

12-
Run: `composer require vivait/string-generator-bundle:^2.0` to install the bundle.
12+
Run: `composer require vivait/string-generator-bundle:^3.0` to install the bundle.
1313

1414
If you are using PHP 5.3 or 5.4 you can use the legacy version`vivait/string-generator-bundle:^1.1`
1515

@@ -203,3 +203,20 @@ public function setOptions(array $options)
203203
$this->prefix = $options['prefix'];
204204
}
205205
```
206+
207+
## Upgrading from version 1 to version 2
208+
Defining generators in configuration was deprecated in version 2 in favour of service definitions, so they must be removed.
209+
210+
1. For any **CUSTOM** generators you have added, you must now define them as services with a `vivait_generator.generator` tag and an `alias` attribute. You will **not** need to do this for the bundled default generators.
211+
212+
```yaml
213+
my_generator:
214+
class: App\Generator\MyGenerator
215+
tags:
216+
- { name: vivait_generator.generator, alias: 'my_generator' }
217+
```
218+
219+
1. Remove all `vivait_string_generator` configuration from your project
220+
221+
## Upgrading from version 2 to version 3
222+
1. Remove all `vivait_string_generator` configuration from your project if not already gone as it will no longer be recognised.

src/Vivait/StringGeneratorBundle/DependencyInjection/Configuration.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Vivait/StringGeneratorBundle/DependencyInjection/VivaitStringGeneratorExtension.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,17 @@
55
use Symfony\Component\Config\FileLocator;
66
use Symfony\Component\DependencyInjection\ContainerBuilder;
77
use Symfony\Component\DependencyInjection\Loader;
8-
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
8+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
99

10-
class VivaitStringGeneratorExtension extends ConfigurableExtension
10+
class VivaitStringGeneratorExtension extends Extension
1111
{
1212

1313
/**
1414
* {@inheritdoc}
1515
*/
16-
public function loadInternal(array $mergedConfig, ContainerBuilder $container)
16+
public function load(array $configs, ContainerBuilder $container)
1717
{
1818
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
1919
$loader->load('services.yml');
20-
21-
if ($mergedConfig['generators'] && $container->hasDefinition('vivait_generator.registry')) {
22-
@trigger_error(
23-
'Defining Generators in config is deprecated since version 2.0.1 and will be removed in version 3.0. ' .
24-
'Use services tagged with "vivait_generator.generator" and an "alias" instead.',
25-
E_USER_DEPRECATED
26-
);
27-
28-
$registry = $container->findDefinition('vivait_generator.registry');
29-
30-
$legacyGenerators = [];
31-
32-
foreach ($mergedConfig['generators'] as $alias => $generatorService) {
33-
$legacyGenerators[$alias] = $container->get($generatorService);
34-
}
35-
36-
$registry->addArgument($legacyGenerators);
37-
}
3820
}
3921
}

src/Vivait/StringGeneratorBundle/Registry/Registry.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@ class Registry
1010
/**
1111
* @var array
1212
*/
13-
private $generators;
14-
15-
/**
16-
* @param array $legacyGenerators
17-
*/
18-
public function __construct(array $legacyGenerators = [])
19-
{
20-
$this->generators = $legacyGenerators;
21-
}
13+
private $generators = [];
2214

2315
/**
2416
* @param GeneratorInterface $generator

0 commit comments

Comments
 (0)