Skip to content

Commit fab1eee

Browse files
bartbrouwerBart Brouwer
andauthored
Remove configuration from XML, use PhpFileLoader for the container configuration (#318)
Co-authored-by: Bart Brouwer <bbrouwer@symphonit.com>
1 parent f28e2aa commit fab1eee

6 files changed

Lines changed: 6 additions & 163 deletions

File tree

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0 || ^8.0"
3333
},
3434
"require-dev": {
35-
"ext-simplexml": "*",
3635
"friendsofphp/php-cs-fixer": "^3.51",
3736
"league/flysystem-async-aws-s3": "^2.0 || ^3.0",
3837
"league/flysystem-aws-s3-v3": "^2.0 || ^3.0",

src/DependencyInjection/OneupFlysystemExtension.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,17 @@ class OneupFlysystemExtension extends Extension
2121

2222
public function load(array $configs, ContainerBuilder $container): void
2323
{
24-
if (class_exists(Loader\XmlFileLoader::class)) {
25-
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
26-
$loaderExt = '.xml';
27-
} else {
28-
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
29-
$loaderExt = '.php';
30-
}
24+
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
3125

32-
$loader->load('factories' . $loaderExt);
26+
$loader->load('factories.php');
3327

3428
$adapterFactories = $this->getFactories($container);
3529

3630
$configuration = new Configuration($adapterFactories);
3731
$config = $this->processConfiguration($configuration, $configs);
3832

39-
$loader->load('adapters' . $loaderExt);
40-
$loader->load('flysystem' . $loaderExt);
33+
$loader->load('adapters.php');
34+
$loader->load('flysystem.php');
4135

4236
$adapters = [];
4337

@@ -52,13 +46,8 @@ public function load(array $configs, ContainerBuilder $container): void
5246

5347
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
5448
{
55-
if (class_exists(Loader\XmlFileLoader::class)) {
56-
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
57-
$loader->load('factories.xml');
58-
} else {
59-
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
60-
$loader->load(resource: 'factories.php');
61-
}
49+
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
50+
$loader->load('factories.php');
6251

6352
$adapterFactories = $this->getFactories($container);
6453

src/Resources/config/adapters.xml

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

src/Resources/config/factories.xml

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

src/Resources/config/flysystem.xml

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

tests/DependencyInjection/OneupFlysystemExtensionTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,6 @@ public function testDirectoryVisibilitySettings(): void
8989
self::assertSame(Visibility::PUBLIC, $directory6Attributes->visibility());
9090
}
9191

92-
public function testAdapterAvailability(): void
93-
{
94-
/** @var \SimpleXMLElement $adapters */
95-
$adapters = simplexml_load_string((string) file_get_contents(__DIR__ . '/../../src/Resources/config/adapters.xml'));
96-
97-
foreach ($adapters->children()->children() as $service) {
98-
if (null === $service->attributes()) {
99-
continue;
100-
}
101-
102-
foreach ($service->attributes() as $key => $attribute) {
103-
if ('class' === (string) $key) {
104-
self::assertTrue(class_exists((string) $attribute), 'Could not load class: ' . $attribute);
105-
}
106-
}
107-
}
108-
}
109-
11092
public function testGetConfiguration(): void
11193
{
11294
$extension = new OneupFlysystemExtension();

0 commit comments

Comments
 (0)