Skip to content

Commit

Permalink
Switch to php config (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
fre5h authored Jul 28, 2022
1 parent 88cc20b commit cb3e104
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 31 deletions.
6 changes: 3 additions & 3 deletions DependencyInjection/StfalconApiExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use StfalconStudio\ApiBundle\Service\Exception\ResponseProcessor\CustomAppExceptionResponseProcessorInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

Expand All @@ -34,8 +34,8 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.php');

$jwtBlackListServiceDefinition = $container->getDefinition(JwtBlackListService::class);
$redisClient = [new Reference($config['redis_client_jwt_black_list'])];
Expand Down
36 changes: 36 additions & 0 deletions Resources/config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/*
* This file is part of the StfalconApiBundle.
*
* (c) Stfalcon LLC <stfalcon.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

use JsonSchema\Validator;
use Predis\Client;
use StfalconStudio\ApiBundle\EventListener\ORM\Aggregate\AggregatePartListener;
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

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

$services
->defaults()
->autowire()
->autoconfigure()
->bind('$apiHost', '%stfalcon_api.api_host%')
->bind('$jsonSchemaDir', '%stfalcon_api.json_schema_dir%')
->bind('$environment', '%env(APP_ENV)%')
->bind('iterable $errorResponseProcessors', new TaggedIteratorArgument('stfalcon_api.exception_response_processor'))
;

$services->load('StfalconStudio\ApiBundle\\', __DIR__.'/../../{Asset,EventListener,Request,Security,Serializer,Service,Util,Validator}/');
$services->set(AggregatePartListener::class, AggregatePartListener::class)->tag('doctrine.event_listener', ['event' => 'onFlush']);
$services->set(Client::class, Client::class);
$services->set(Validator::class, Validator::class);
};
24 changes: 0 additions & 24 deletions Resources/config/services.yaml

This file was deleted.

10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@
"symfony/framework-bundle": "^6.1",
"symfony/serializer": "^6.1",
"symfony/translation": "^6.1",
"symfony/validator": "^6.1",
"symfony/yaml": "^6.1"
"symfony/validator": "^6.1"
},
"require-dev": {
"escapestudios/symfony2-coding-standard": "^3.12",
"jetbrains/phpstorm-attributes": "^1.0",
"phpstan/phpstan": "^1.7.15",
"phpstan/phpstan": "^1.8.2",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-phpunit": "^1.1",
Expand Down Expand Up @@ -74,6 +73,9 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"symfony/flex": true
}
}
}

0 comments on commit cb3e104

Please sign in to comment.