Skip to content

Commit 500e735

Browse files
committed
Move service declaration to PHP
1 parent d683172 commit 500e735

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
## Warning
1212

13-
This plugin DO NOT follow standard Sylius directory structure for plugins but a new "Symfony standard skeleton" one.
13+
This plugin DO NOT follow standard Sylius directory structure for plugins but a new "Symfony standard skeleton" one
14+
and services declaration in PHP (Symfony is actually leaving xml for PHP).
1415

1516
New directory structure:
1617

config/services.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
6+
7+
return static function (ContainerConfigurator $configurator) {
8+
$configurator->import('services/*');
9+
};

config/services.xml

-8
This file was deleted.

config/services/controller.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
6+
7+
use Acme\SyliusExamplePlugin\Controller\GreetingController;
8+
9+
return function (ContainerConfigurator $configurator) {
10+
$services = $configurator->services();
11+
12+
$services->set(GreetingController::class)
13+
->autowire()
14+
->autoconfigure()
15+
->public();
16+
};

src/DependencyInjection/AcmeSyliusExampleExtension.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
use Symfony\Component\Config\FileLocator;
99
use Symfony\Component\DependencyInjection\ContainerBuilder;
1010
use Symfony\Component\DependencyInjection\Extension\Extension;
11-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
11+
use Symfony\Component\DependencyInjection\Loader\FileLoader;
12+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
1213

1314
final class AcmeSyliusExampleExtension extends Extension
1415
{
1516
public function load(array $configs, ContainerBuilder $container): void
1617
{
1718
$config = $this->processConfiguration($this->getConfiguration([], $container), $configs);
18-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
19+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
1920

20-
$loader->load('services.xml');
21+
$loader->load('services.php');
2122
}
2223

2324
public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface

0 commit comments

Comments
 (0)