Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Move configuration to PHP #70

Merged
merged 2 commits into from
Jul 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"cs": "PHP_CS_FIXER_IGNORE_ENV=1 && vendor/bin/php-cs-fixer fix --verbose",
"cs-diff": "PHP_CS_FIXER_IGNORE_ENV=1 && vendor/bin/php-cs-fixer fix --verbose --diff --diff-format=udiff --dry-run",
"deps": "vendor/bin/composer-require-checker check --config-file composer-require.json composer.json",
"infection": "vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=25 --min-msi=18",
"infection": "vendor/bin/infection",
"lint": [
"find ./src \\( -name '*.xml' -or -name '*.xml.dist' -or -name '*.xlf' \\) -type f -exec xmllint --encode UTF-8 --output '{}' --format '{}' \\;",
"find ./src \\( -name '*.yml' -or -name '*.yaml' \\) -not -path '*/vendor/*' | xargs yaml-lint"
Expand Down
21 changes: 12 additions & 9 deletions infection.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"timeout": 10,
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "build/infection/infection-log.txt"
}
"timeout": 10,
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "build/infection/infection-log.txt"
},
"ignoreMsiWithNoMutations": true,
"minMsi": 18,
"minCoveredMsi": 25
}
8 changes: 4 additions & 4 deletions src/DependencyInjection/NucleosShariffExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('action.xml');
$loader->load('block.xml');
$loader->load('services.xml');
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('action.php');
$loader->load('block.php');
$loader->load('services.php');

$this->configureAliases($container, $config);
$this->configureDomains($container, $config);
Expand Down
26 changes: 26 additions & 0 deletions src/Resources/config/action.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Nucleos\ShariffBundle\Action\BackendAction;
use Nucleos\ShariffBundle\Backend\Backend;
use Symfony\Component\DependencyInjection\Reference;

return static function (ContainerConfigurator $container): void {
$container->services()

->set(BackendAction::class)
->public()
->args([
new Reference(Backend::class),
])

;
};
9 changes: 0 additions & 9 deletions src/Resources/config/action.xml

This file was deleted.

25 changes: 25 additions & 0 deletions src/Resources/config/block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Nucleos\ShariffBundle\Block\Service\ShariffShareBlockService;
use Symfony\Component\DependencyInjection\Reference;

return static function (ContainerConfigurator $container): void {
$container->services()

->set('nucleos_shariff.block.share', ShariffShareBlockService::class)
->tag('sonata.block')
->args([
new Reference('twig'),
])

;
};
9 changes: 0 additions & 9 deletions src/Resources/config/block.xml

This file was deleted.

63 changes: 63 additions & 0 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Nucleos\ShariffBundle\Backend\Backend;
use Nucleos\ShariffBundle\Backend\PsrBackend;
use Nucleos\ShariffBundle\Manager\ServiceManager;
use Nucleos\ShariffBundle\Manager\StaticServiceManager;
use Nucleos\ShariffBundle\Service\Facebook;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Reference;

return static function (ContainerConfigurator $container): void {
$services = $container->services();

$services->load('Nucleos\\ShariffBundle\\Service\\', '../../Service')
->exclude('../../Service/{Exception}')
->public()
->autowire()
->autoconfigure()
;

$services
->set(Facebook::class)
->tag('nucleos.shariff')
->args([
new Parameter('nucleos_shariff.service.facebook.app_id'),
new Parameter('nucleos_shariff.service.facebook.secret'),
new Parameter('nucleos_shariff.service.facebook.version'),
])

->set(StaticServiceManager::class)
->args([
[],
new Parameter('nucleos_shariff.services'),
])

->set(PsrBackend::class)
->args([
new Reference(ServiceManager::class),
new Reference('nucleos_shariff.request_factory'),
new Reference('nucleos_shariff.http_client'),
new Reference('nucleos_shariff.cache'),
new Parameter('nucleos_shariff.domains'),
])
->call('setLogger', [
new Reference('logger', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE),
])

->alias(ServiceManager::class, StaticServiceManager::class)

->alias(Backend::class, PsrBackend::class)

;
};
30 changes: 0 additions & 30 deletions src/Resources/config/services.xml

This file was deleted.

12 changes: 6 additions & 6 deletions vendor-bin/test/composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"require": {
"infection/infection": "^0.15",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"phpunit/phpunit": "^9.0",
"symfony/phpunit-bridge": "^5.1"
}
"require": {
"infection/infection": "^0.16",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"phpunit/phpunit": "^9.0",
"symfony/phpunit-bridge": "^5.1"
}
}