Skip to content
Open
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
8 changes: 6 additions & 2 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ jobs:
- '8.2'
- '8.3'
- '8.4'
- '8.5'
symfony:
- '6.4.*'
- '7.1.*'
- '7.4.*'
- '8.0.*'
elasticsearch:
- '8.12.0'
dependencies:
Expand Down Expand Up @@ -99,9 +101,11 @@ jobs:
- '8.2'
- '8.3'
- '8.4'
- '8.5'
symfony:
- '6.4.*'
- '7.1.*'
- '7.4.*'
- '8.0.*'
dependencies:
- 'highest'
include:
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
"pagerfanta/pagerfanta": "^3.0 || ^4.0",
"psr/log": "^3.0",
"ruflin/elastica": "^8.0",
"symfony/console": "^6.4 || ^7.1",
"symfony/dependency-injection": "^6.4 || ^7.1",
"symfony/event-dispatcher": "^6.4 || ^7.1",
"symfony/framework-bundle": "^6.4 || ^7.1",
"symfony/property-access": "^6.4 || ^7.1",
"symfony/stopwatch": "^6.4 || ^7.1"
"symfony/console": "^6.4 || ^7.4 || ^8.0",
"symfony/dependency-injection": "^6.4 || ^7.4 || ^8.0",
"symfony/event-dispatcher": "^6.4 || ^7.4 || ^8.0",
"symfony/framework-bundle": "^6.4 || ^7.4 || ^8.0",
"symfony/property-access": "^6.4 || ^7.4 || ^8.0",
"symfony/stopwatch": "^6.4 || ^7.4 || ^8.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.1.1",
Expand All @@ -57,12 +57,12 @@
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-symfony": "^1.4",
"phpunit/phpunit": "^9.5",
"symfony/expression-language": "^6.4 || ^7.1",
"symfony/messenger": "^6.4 || ^7.1",
"symfony/serializer": "^6.4 || ^7.1",
"symfony/twig-bundle": "^6.4 || ^7.1",
"symfony/web-profiler-bundle": "^6.4 || ^7.1",
"symfony/yaml": "^6.4 || ^7.1"
"symfony/expression-language": "^6.4 || ^7.4 || ^8.0",
"symfony/messenger": "^6.4 || ^7.4 || ^8.0",
"symfony/serializer": "^6.4 || ^7.4 || ^8.0",
"symfony/twig-bundle": "^6.4 || ^7.4 || ^8.0",
"symfony/web-profiler-bundle": "^6.4 || ^7.4 || ^8.0",
"symfony/yaml": "^6.4 || ^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.12.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Command/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('fos:elastica:create')
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('fos:elastica:delete')
Expand Down
4 changes: 2 additions & 2 deletions src/Command/PopulateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('fos:elastica:populate')
Expand All @@ -88,7 +88,7 @@ protected function configure()
/**
* @return void
*/
protected function initialize(InputInterface $input, OutputInterface $output)
protected function initialize(InputInterface $input, OutputInterface $output): void
{
$this->pagerPersister = $this->pagerPersisterRegistry->getPagerPersister($input->getOption('pager-persister'));

Expand Down
2 changes: 1 addition & 1 deletion src/Command/ResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('fos:elastica:reset')
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ResetTemplatesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('fos:elastica:reset-templates')
Expand Down
2 changes: 1 addition & 1 deletion src/Command/SearchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(IndexManager $indexManager)
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setName('fos:elastica:search')
Expand Down
2 changes: 1 addition & 1 deletion src/DataCollector/ElasticaDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(ElasticaLogger $logger)
/**
* @return void
*/
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
{
$this->data['nb_queries'] = $this->logger->getNbQueries();
$this->data['queries'] = $this->logger->getQueries();
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/ConfigSourcePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ConfigSourcePass implements CompilerPassInterface
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('fos_elastica.config_manager')) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/IndexPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class IndexPass implements CompilerPassInterface
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('fos_elastica.index_manager')) {
return;
Expand Down
18 changes: 9 additions & 9 deletions src/DependencyInjection/FOSElasticaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Messenger\MessageBusInterface;

Expand Down Expand Up @@ -72,15 +72,15 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

if (empty($config['clients']) || empty($config['indexes'])) {
// No Clients or indexes are defined
return;
}

foreach (['config', 'index', 'persister', 'provider', 'source', 'transformer', 'event_listener', 'commands'] as $basename) {
$loader->load(\sprintf('%s.xml', $basename));
$loader->load(\sprintf('%s.php', $basename));
}

if (empty($config['default_client'])) {
Expand All @@ -98,7 +98,7 @@ public function load(array $configs, ContainerBuilder $container): void
}

if (isset($config['serializer'])) {
$loader->load('serializer.xml');
$loader->load('serializer.php');

$this->loadSerializer($config['serializer'], $container);
}
Expand Down Expand Up @@ -142,7 +142,7 @@ public function load(array $configs, ContainerBuilder $container): void
*
* @return Configuration
*/
public function getConfiguration(array $config, ContainerBuilder $container)
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
{
return new Configuration($container->getParameter('kernel.debug'));
}
Expand Down Expand Up @@ -759,8 +759,8 @@ private function loadDriver(ContainerBuilder $container, string $driver): void
return;
}

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load($driver.'.xml');
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load($driver.'.php');
$this->loadedDrivers[] = $driver;
}

Expand Down Expand Up @@ -820,13 +820,13 @@ private function getClient(string $clientName): Reference
return $this->clients[$clientName]['reference'];
}

private function registerMessengerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader): void
private function registerMessengerConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
{
if (!\interface_exists(MessageBusInterface::class)) {
throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
}

$loader->load('messenger.xml');
$loader->load('messenger.php');

$container->setAlias('fos_elastica.messenger.bus', $config['bus']);
}
Expand Down
2 changes: 1 addition & 1 deletion src/FOSElasticaBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FOSElasticaBundle extends Bundle
/**
* @return void
*/
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
parent::build($container);

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

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use FOS\ElasticaBundle\Command\CreateCommand;
use FOS\ElasticaBundle\Command\DeleteCommand;
use FOS\ElasticaBundle\Command\PopulateCommand;
use FOS\ElasticaBundle\Command\ResetCommand;
use FOS\ElasticaBundle\Command\ResetTemplatesCommand;
use FOS\ElasticaBundle\Command\SearchCommand;

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

$services->set('fos_elastica.command.create', CreateCommand::class)
->tag('console.command', ['command' => 'fos:elastica:create'])
->args([
service('fos_elastica.index_manager'),
service('fos_elastica.mapping_builder'),
service('fos_elastica.config_manager'),
service('fos_elastica.alias_processor'),
]);

$services->set('fos_elastica.command.delete', DeleteCommand::class)
->tag('console.command', ['command' => 'fos:elastica:delete'])
->args([service('fos_elastica.index_manager')]);

$services->set('fos_elastica.command.populate', PopulateCommand::class)
->tag('console.command', ['command' => 'fos:elastica:populate'])
->args([
service('event_dispatcher'),
service('fos_elastica.index_manager'),
service('fos_elastica.pager_provider_registry'),
service('fos_elastica.pager_persister_registry'),
service('fos_elastica.resetter'),
]);

$services->set('fos_elastica.command.reset', ResetCommand::class)
->tag('console.command', ['command' => 'fos:elastica:reset'])
->args([
service('fos_elastica.index_manager'),
service('fos_elastica.resetter'),
]);

$services->set('fos_elastica.command.templates_reset', ResetTemplatesCommand::class)
->tag('console.command', ['command' => 'fos:elastica:reset-templates'])
->args([service('fos_elastica.template_resetter')]);

$services->set('fos_elastica.command.search', SearchCommand::class)
->tag('console.command', ['command' => 'fos:elastica:search'])
->args([service('fos_elastica.index_manager')]);
};
46 changes: 0 additions & 46 deletions src/Resources/config/commands.xml

This file was deleted.

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

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use FOS\ElasticaBundle\Configuration\ConfigManager;
use FOS\ElasticaBundle\DataCollector\ElasticaDataCollector;
use FOS\ElasticaBundle\Elastica\Client;
use FOS\ElasticaBundle\Elastica\NodePool\RoundRobinNoResurrect;
use FOS\ElasticaBundle\Elastica\NodePool\RoundRobinResurrect;
use FOS\ElasticaBundle\Index\MappingBuilder;
use FOS\ElasticaBundle\Logger\ElasticaLogger;
use FOS\ElasticaBundle\Subscriber\PaginateElasticaQuerySubscriber;
use Symfony\Component\PropertyAccess\PropertyAccessor;

return static function (ContainerConfigurator $container): void {
$container->parameters()
->set('fos_elastica.property_accessor.magicCall', 0)
->set('fos_elastica.property_accessor.throwExceptionOnInvalidIndex', 0);

$services = $container->services();

$services->set('fos_elastica.client_prototype', Client::class)
->abstract()
->arg('$config', abstract_arg('configuration for Ruflin Client'))
->arg('$forbiddenCodes', abstract_arg('list of forbidden codes for Client'))
->arg('$logger', abstract_arg('logger for Ruflin Client'))
->call('setStopwatch', [service('debug.stopwatch')->nullOnInvalid()])
->call('setEventDispatcher', [service('event_dispatcher')->nullOnInvalid()]);

$services->set(RoundRobinResurrect::class)
->factory([null, 'create']);

$services->set(RoundRobinNoResurrect::class)
->factory([null, 'create']);

$services->set('fos_elastica.config_manager', ConfigManager::class)
->args([[]]);
$services->alias(ConfigManager::class, 'fos_elastica.config_manager');

$services->set('fos_elastica.config_manager.index_templates', ConfigManager::class)
->args([[]]);

$services->set('fos_elastica.data_collector', ElasticaDataCollector::class)
->tag('data_collector', ['template' => '@FOSElastica/Collector/elastica.html.twig', 'id' => 'elastica'])
->args([service('fos_elastica.logger')]);

$services->set('fos_elastica.paginator.subscriber', PaginateElasticaQuerySubscriber::class)
->tag('kernel.event_subscriber')
->args([service('request_stack')]);

$services->set('fos_elastica.logger', ElasticaLogger::class)
->args([service('logger')->nullOnInvalid(), '%kernel.debug%'])
->tag('monolog.logger', ['channel' => 'elastica']);

$services->set('fos_elastica.mapping_builder', MappingBuilder::class)
->args([service('event_dispatcher')]);

$services->set('fos_elastica.property_accessor', PropertyAccessor::class)
->args(['%fos_elastica.property_accessor.magicCall%', '%fos_elastica.property_accessor.throwExceptionOnInvalidIndex%']);
};
Loading
Loading