Skip to content

Commit 0887847

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

File tree

11 files changed

+100
-107
lines changed

11 files changed

+100
-107
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

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@
7474
"symfony/var-exporter": "^5.4 || ^6.4 || ^7.0",
7575
"symfony/yaml": "^5.4 || ^6.4 || ^7.0"
7676
},
77-
"conflict": {
78-
"geocoder-php/nominatim-provider": "<5.0"
79-
},
8077
"autoload": {
8178
"psr-4": {
8279
"Bazinga\\GeocoderBundle\\": "src/"
@@ -88,7 +85,7 @@
8885
}
8986
},
9087
"scripts": {
91-
"test": "vendor/bin/simple-phpunit --testsuite main"
88+
"test": "SYMFONY_DEPRECATIONS_HELPER=ignoreFile='./tests/baseline-ignore' vendor/bin/simple-phpunit --testsuite main"
9289
},
9390
"config": {
9491
"allow-plugins": {

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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
->public();
23+
24+
$services
25+
->set(GeoArray::class)
26+
->set(GeoJson::class)
27+
->set(Gpx::class)
28+
->set(Kml::class)
29+
->set(Wkb::class)
30+
->set(Wkt::class)
31+
32+
->load('Bazinga\\GeocoderBundle\\ProviderFactory\\', __DIR__.'/../src/ProviderFactory')
33+
->autowire()
34+
->autoconfigure()
35+
36+
->set(ProviderAggregator::class)
37+
38+
->set(FakeIpPlugin::class)
39+
->args([null, null, false])
40+
41+
->set(GeocodeCommand::class)
42+
->args([
43+
service(ProviderAggregator::class),
44+
])
45+
->tag('console.command')
46+
47+
->set(AddressValidator::class)
48+
->args([
49+
service(ProviderAggregator::class),
50+
])
51+
->tag('validator.constraint_validator')
52+
;
53+
};

config/services.yml

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

src/Command/GeocodeCommand.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,18 @@
2424
/**
2525
* @author Markus Bachmann <markus.bachmann@bachi.biz>
2626
*/
27-
#[AsCommand(name: 'geocoder:geocode', description: 'Geocode an address or a ip address')]
27+
#[AsCommand(
28+
name: 'geocoder:geocode',
29+
description: 'Geocode an address or an IP address',
30+
help: <<<'HELP'
31+
The <info>geocoder:geocoder</info> command will fetch the latitude
32+
and longitude from the given address.
33+
34+
You can force a provider with the "provider" option.
35+
36+
<info>php bin/console geocoder:geocoder "Eiffel Tower" --provider=yahoo</info>
37+
HELP
38+
)]
2839
class GeocodeCommand extends Command
2940
{
3041
private ProviderAggregator $geocoder;
@@ -43,16 +54,7 @@ protected function configure()
4354
{
4455
$this
4556
->addArgument('address', InputArgument::REQUIRED, 'The address')
46-
->addOption('provider', null, InputOption::VALUE_OPTIONAL)
47-
->setHelp(<<<'HELP'
48-
The <info>geocoder:geocoder</info> command will fetch the latitude
49-
and longitude from the given address.
50-
51-
You can force a provider with the "provider" option.
52-
53-
<info>php bin/console geocoder:geocoder "Eiffel Tower" --provider=yahoo</info>
54-
HELP
55-
);
57+
->addOption('provider', null, InputOption::VALUE_OPTIONAL);
5658
}
5759

5860
protected function execute(InputInterface $input, OutputInterface $output): int

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)