Skip to content

Commit 492e03c

Browse files
committed
Switch from yaml to php format services definition
1 parent 7e9948b commit 492e03c

File tree

8 files changed

+87
-92
lines changed

8 files changed

+87
-92
lines changed

.editorconfig

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,18 @@ indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.{yml,yaml}]
11+
[.github/**/*.{yml,yaml}]
1212
indent_size = 2
13+
14+
[*.{yml,yaml}]
15+
trim_trailing_whitespace = false
16+
17+
[**.md]
18+
indent_size = unset
19+
indent_style = unset
20+
21+
[*.json]
22+
insert_final_newline = false
23+
24+
[*.{neon,neon.dist}]
25+
indent_style = tab

config/profiling.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
6+
7+
use Bazinga\GeocoderBundle\DataCollector\GeocoderDataCollector;
8+
9+
return static function (ContainerConfigurator $container) {
10+
$services = $container->services();
11+
12+
$services->set(GeocoderDataCollector::class)
13+
->tag('data_collector', ['template' => '@BazingaGeocoder/Collector/geocoder.html.twig', 'id' => 'geocoder']);
14+
};

config/profiling.yml

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

config/services.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
6+
7+
use Bazinga\GeocoderBundle\Command\GeocodeCommand;
8+
use Bazinga\GeocoderBundle\Plugin\FakeIpPlugin;
9+
use Bazinga\GeocoderBundle\Validator\Constraint\AddressValidator;
10+
use Geocoder\Dumper\Dumper;
11+
use Geocoder\Dumper\GeoArray;
12+
use Geocoder\Dumper\GeoJson;
13+
use Geocoder\Dumper\Gpx;
14+
use Geocoder\Dumper\Kml;
15+
use Geocoder\Dumper\Wkb;
16+
use Geocoder\Dumper\Wkt;
17+
use Geocoder\ProviderAggregator;
18+
19+
return static function (ContainerConfigurator $container) {
20+
$services = $container->services();
21+
$services->instanceof(Dumper::class)
22+
->tag('bazinga_geocoder.dumper')
23+
->public();
24+
25+
$services
26+
->set(GeoArray::class)
27+
->set(GeoJson::class)
28+
->set(Gpx::class)
29+
->set(Kml::class)
30+
->set(Wkb::class)
31+
->set(Wkt::class)
32+
33+
->load('Bazinga\\GeocoderBundle\\ProviderFactory\\', __DIR__.'/../src/ProviderFactory')
34+
->autowire()
35+
->autoconfigure()
36+
->private()
37+
38+
->set(ProviderAggregator::class)
39+
40+
->set(FakeIpPlugin::class)
41+
->args([null, null, false])
42+
43+
->set(GeocodeCommand::class)
44+
->args([
45+
service(ProviderAggregator::class),
46+
])
47+
->tag('console.command', ['command' => 'geocoder:geocode', 'description' => 'Geocode an address or a ip address'])
48+
49+
->set(AddressValidator::class)
50+
->args([
51+
service(ProviderAggregator::class),
52+
])
53+
->tag('validator.constraint_validator')
54+
;
55+
};

config/services.yml

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

src/DependencyInjection/BazingaGeocoderExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
use Symfony\Component\DependencyInjection\ContainerBuilder;
3232
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
3333
use Symfony\Component\DependencyInjection\Extension\Extension;
34-
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
34+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
3535
use Symfony\Component\DependencyInjection\Reference;
3636

3737
/**
@@ -50,11 +50,11 @@ public function load(array $configs, ContainerBuilder $container)
5050
$configuration = $this->getConfiguration($configs, $container);
5151
$config = $processor->processConfiguration($configuration, $configs);
5252

53-
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
54-
$loader->load('services.yml');
53+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../config'));
54+
$loader->load('services.php');
5555

5656
if (true === $config['profiling']['enabled']) {
57-
$loader->load('profiling.yml');
57+
$loader->load('profiling.php');
5858
}
5959

6060
if ($config['fake_ip']['enabled']) {

tests/Functional/BundleInitializationTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -160,28 +160,6 @@ public function testBundleWithPluginsYml(): void
160160
self::assertInstanceOf(LoggerPlugin::class, $plugins[0]);
161161
}
162162

163-
public function testBundleWithPluginXml(): void
164-
{
165-
self::bootKernel(['config' => static function (TestKernel $kernel) {
166-
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
167-
168-
if ($kernel::VERSION_ID >= 60000) {
169-
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
170-
}
171-
172-
$kernel->addTestConfig(__DIR__.'/config/service_plugin.xml');
173-
}]);
174-
175-
$container = self::getContainer();
176-
177-
self::assertTrue($container->has('bazinga_geocoder.provider.acme'));
178-
$service = $container->get('bazinga_geocoder.provider.acme');
179-
self::assertInstanceOf(PluginProvider::class, $service);
180-
$plugins = NSA::getProperty($service, 'plugins');
181-
self::assertNotEmpty($plugins);
182-
self::assertInstanceOf(LoggerPlugin::class, $plugins[0]);
183-
}
184-
185163
public function testBundleHasRegisteredDumpers(): void
186164
{
187165
self::bootKernel(['config' => static function (TestKernel $kernel) {

tests/Functional/config/service_plugin.xml

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

0 commit comments

Comments
 (0)