diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 05a07bc7f..9022f380e 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -41,16 +41,17 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' symfony: - '6.4.*' - - '7.1.*' + - '7.4.*' elasticsearch: - '8.12.0' dependencies: - 'highest' exclude: - php: '8.1' - symfony: '7.1.*' + symfony: '7.4.*' fail-fast: false steps: - name: 'Checkout' @@ -99,9 +100,10 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' symfony: - '6.4.*' - - '7.1.*' + - '7.4.*' dependencies: - 'highest' include: @@ -110,7 +112,7 @@ jobs: symfony: '6.4.*' exclude: - php: '8.1' - symfony: '7.1.*' + symfony: '7.4.*' fail-fast: false steps: diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 2b52e2625..2ced26287 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -22,6 +22,7 @@ 'native_constant_invocation' => true, 'native_function_invocation' => [ 'include' => ['@all'], + 'exclude' => ['service', 'abstract_arg', 'param', 'tagged_locator', 'tagged_iterator', 'inline_service', 'env'], ], 'no_alias_functions' => true, 'nullable_type_declaration_for_default_null_value' => true, diff --git a/composer.json b/composer.json index 39cec806e..f60b3a96c 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -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" diff --git a/phpstan.dist.neon b/phpstan.dist.neon index cb09a8c75..2d5b76bce 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -33,3 +33,6 @@ parameters: path: src/Finder/PaginatedHybridFinderInterface.php - message: '/PHPDoc tag @return contains generic type Pagerfanta\\PagerfantaInterface but interface Pagerfanta\\PagerfantaInterface is not generic/' path: src/Finder/PaginatedRawFinderInterface.php + # Symfony 7.4+ added generic type annotations to Config component classes + - message: '/Call to method \w+\(\) on an unknown class Symfony\\Component\\Config\\Definition\\Builder\\\w+<.*>/' + path: src/DependencyInjection/Configuration.php diff --git a/src/Command/CreateCommand.php b/src/Command/CreateCommand.php index 4bcdbfa7f..df0be75d1 100644 --- a/src/Command/CreateCommand.php +++ b/src/Command/CreateCommand.php @@ -45,10 +45,7 @@ public function __construct( $this->aliasProcessor = $aliasProcessor; } - /** - * @return void - */ - protected function configure() + protected function configure(): void { $this ->setName('fos:elastica:create') diff --git a/src/Command/DeleteCommand.php b/src/Command/DeleteCommand.php index 095118b46..19393432c 100644 --- a/src/Command/DeleteCommand.php +++ b/src/Command/DeleteCommand.php @@ -33,10 +33,7 @@ public function __construct( $this->indexManager = $indexManager; } - /** - * @return void - */ - protected function configure() + protected function configure(): void { $this ->setName('fos:elastica:delete') diff --git a/src/Command/PopulateCommand.php b/src/Command/PopulateCommand.php index 21cc10ca3..c21d4960e 100644 --- a/src/Command/PopulateCommand.php +++ b/src/Command/PopulateCommand.php @@ -62,10 +62,7 @@ public function __construct( $this->resetter = $resetter; } - /** - * @return void - */ - protected function configure() + protected function configure(): void { $this ->setName('fos:elastica:populate') @@ -85,10 +82,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')); diff --git a/src/Command/ResetCommand.php b/src/Command/ResetCommand.php index d495a4f36..8763a7204 100644 --- a/src/Command/ResetCommand.php +++ b/src/Command/ResetCommand.php @@ -36,10 +36,7 @@ public function __construct( $this->resetter = $resetter; } - /** - * @return void - */ - protected function configure() + protected function configure(): void { $this ->setName('fos:elastica:reset') diff --git a/src/Command/ResetTemplatesCommand.php b/src/Command/ResetTemplatesCommand.php index a0de72423..014ba1fd9 100644 --- a/src/Command/ResetTemplatesCommand.php +++ b/src/Command/ResetTemplatesCommand.php @@ -34,10 +34,7 @@ public function __construct( $this->resetter = $resetter; } - /** - * @return void - */ - protected function configure() + protected function configure(): void { $this ->setName('fos:elastica:reset-templates') diff --git a/src/Command/SearchCommand.php b/src/Command/SearchCommand.php index b03a744d6..348430669 100644 --- a/src/Command/SearchCommand.php +++ b/src/Command/SearchCommand.php @@ -34,10 +34,7 @@ public function __construct(IndexManager $indexManager) $this->indexManager = $indexManager; } - /** - * @return void - */ - protected function configure() + protected function configure(): void { $this ->setName('fos:elastica:search') diff --git a/src/DataCollector/ElasticaDataCollector.php b/src/DataCollector/ElasticaDataCollector.php index 6e883e9df..2574f361a 100644 --- a/src/DataCollector/ElasticaDataCollector.php +++ b/src/DataCollector/ElasticaDataCollector.php @@ -30,10 +30,7 @@ public function __construct(ElasticaLogger $logger) $this->logger = $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(); diff --git a/src/DependencyInjection/Compiler/ConfigSourcePass.php b/src/DependencyInjection/Compiler/ConfigSourcePass.php index c105bed8d..53bf91255 100644 --- a/src/DependencyInjection/Compiler/ConfigSourcePass.php +++ b/src/DependencyInjection/Compiler/ConfigSourcePass.php @@ -19,10 +19,7 @@ class ConfigSourcePass implements CompilerPassInterface { public const SOURCE_TYPE_INDEX_TEMPLATE = 'index_template'; - /** - * @return void - */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('fos_elastica.config_manager')) { return; diff --git a/src/DependencyInjection/Compiler/IndexPass.php b/src/DependencyInjection/Compiler/IndexPass.php index a171f1a39..dc9560264 100644 --- a/src/DependencyInjection/Compiler/IndexPass.php +++ b/src/DependencyInjection/Compiler/IndexPass.php @@ -17,10 +17,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; diff --git a/src/DependencyInjection/FOSElasticaExtension.php b/src/DependencyInjection/FOSElasticaExtension.php index 4a3de725f..e17b2c866 100644 --- a/src/DependencyInjection/FOSElasticaExtension.php +++ b/src/DependencyInjection/FOSElasticaExtension.php @@ -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; @@ -72,7 +72,7 @@ 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 @@ -80,7 +80,7 @@ public function load(array $configs, ContainerBuilder $container): void } 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'])) { @@ -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); } @@ -139,10 +139,8 @@ public function load(array $configs, ContainerBuilder $container): void /** * @param array $config - * - * @return Configuration */ - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): Configuration { return new Configuration($container->getParameter('kernel.debug')); } @@ -759,8 +757,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; } @@ -820,13 +818,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']); } diff --git a/src/FOSElasticaBundle.php b/src/FOSElasticaBundle.php index 07bd86a2b..4e38b8215 100644 --- a/src/FOSElasticaBundle.php +++ b/src/FOSElasticaBundle.php @@ -18,10 +18,7 @@ class FOSElasticaBundle extends Bundle { - /** - * @return void - */ - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { parent::build($container); diff --git a/src/Resources/config/commands.php b/src/Resources/config/commands.php new file mode 100644 index 000000000..992abd928 --- /dev/null +++ b/src/Resources/config/commands.php @@ -0,0 +1,73 @@ + + * + * 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 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'), + ]) + ; +}; diff --git a/src/Resources/config/commands.xml b/src/Resources/config/commands.xml deleted file mode 100644 index 01f0f70f4..000000000 --- a/src/Resources/config/commands.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/config.php b/src/Resources/config/config.php new file mode 100644 index 000000000..a5c9128cb --- /dev/null +++ b/src/Resources/config/config.php @@ -0,0 +1,86 @@ + + * + * 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 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(), + param('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([ + param('fos_elastica.property_accessor.magicCall'), + param('fos_elastica.property_accessor.throwExceptionOnInvalidIndex'), + ]) + ; +}; diff --git a/src/Resources/config/config.xml b/src/Resources/config/config.xml deleted file mode 100644 index 4a9972d65..000000000 --- a/src/Resources/config/config.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - 0 - 0 - - - - - configuration for Ruflin Client - list of forbidden codes for Client - logger for Ruflin Client - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %kernel.debug% - - - - - - - - - %fos_elastica.property_accessor.magicCall% - %fos_elastica.property_accessor.throwExceptionOnInvalidIndex% - - - diff --git a/src/Resources/config/event_listener.php b/src/Resources/config/event_listener.php new file mode 100644 index 000000000..e7915149b --- /dev/null +++ b/src/Resources/config/event_listener.php @@ -0,0 +1,24 @@ + + * + * 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 FOS\ElasticaBundle\Event\PostIndexPopulateEvent; +use FOS\ElasticaBundle\EventListener\PopulateListener; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.populate_listener', PopulateListener::class) + ->tag('kernel.event_listener', ['event' => PostIndexPopulateEvent::class, 'method' => 'onPostIndexPopulate', 'priority' => -9999]) + ->args([service('fos_elastica.resetter')]) + ; +}; diff --git a/src/Resources/config/event_listener.xml b/src/Resources/config/event_listener.xml deleted file mode 100644 index 6b1f92381..000000000 --- a/src/Resources/config/event_listener.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - diff --git a/src/Resources/config/index.php b/src/Resources/config/index.php new file mode 100644 index 000000000..7fff744ed --- /dev/null +++ b/src/Resources/config/index.php @@ -0,0 +1,86 @@ + + * + * 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 FOS\ElasticaBundle\Elastica\Index; +use FOS\ElasticaBundle\Elastica\IndexTemplate; +use FOS\ElasticaBundle\Finder\TransformedFinder; +use FOS\ElasticaBundle\Index\AliasProcessor; +use FOS\ElasticaBundle\Index\IndexManager; +use FOS\ElasticaBundle\Index\IndexTemplateManager; +use FOS\ElasticaBundle\Index\Resetter; +use FOS\ElasticaBundle\Index\TemplateResetter; +use FOS\ElasticaBundle\Manager\RepositoryManager; +use FOS\ElasticaBundle\Provider\Indexable; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.repository_manager', RepositoryManager::class); + + $services->set('fos_elastica.alias_processor', AliasProcessor::class); + + $services->set('fos_elastica.indexable', Indexable::class) + ->args([[]]) + ; + + $services->set('fos_elastica.index_prototype', Index::class) + ->abstract() + ->args([abstract_arg('index name')]) + ; + + $services->set('fos_elastica.index_template_prototype', IndexTemplate::class) + ->abstract() + ->args([abstract_arg('index template name')]) + ; + + $services->set('fos_elastica.index_manager', IndexManager::class) + ->args([ + abstract_arg('indexes'), + service('fos_elastica.index'), + ]) + ; + $services->alias(IndexManager::class, 'fos_elastica.index_manager'); + + $services->set('fos_elastica.index_template_manager', IndexTemplateManager::class) + ->args([abstract_arg('indexes templates')]) + ; + $services->alias(IndexTemplateManager::class, 'fos_elastica.index_template_manager'); + + $services->set('fos_elastica.resetter', Resetter::class) + ->args([ + service('fos_elastica.config_manager'), + service('fos_elastica.index_manager'), + service('fos_elastica.alias_processor'), + service('fos_elastica.mapping_builder'), + service('event_dispatcher'), + ]) + ; + $services->alias(Resetter::class, 'fos_elastica.resetter'); + + $services->set('fos_elastica.template_resetter', TemplateResetter::class) + ->args([ + service('fos_elastica.config_manager.index_templates'), + service('fos_elastica.mapping_builder'), + service('fos_elastica.index_template_manager'), + ]) + ; + $services->alias(TemplateResetter::class, 'fos_elastica.template_resetter'); + + $services->set('fos_elastica.finder', TransformedFinder::class) + ->abstract() + ->args([ + abstract_arg('searchable'), + abstract_arg('transformer'), + ]) + ; +}; diff --git a/src/Resources/config/index.xml b/src/Resources/config/index.xml deleted file mode 100644 index 97c3a3d53..000000000 --- a/src/Resources/config/index.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/messenger.php b/src/Resources/config/messenger.php new file mode 100644 index 000000000..5811b2257 --- /dev/null +++ b/src/Resources/config/messenger.php @@ -0,0 +1,27 @@ + + * + * 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 FOS\ElasticaBundle\Persister\AsyncPagerPersister; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.async_pager_persister', AsyncPagerPersister::class) + ->args([ + service('fos_elastica.pager_persister_registry'), + service('fos_elastica.pager_provider_registry'), + service('fos_elastica.messenger.bus'), + ]) + ->tag('fos_elastica.pager_persister', ['persisterName' => 'async']) + ; +}; diff --git a/src/Resources/config/messenger.xml b/src/Resources/config/messenger.xml deleted file mode 100644 index 56992f6ad..000000000 --- a/src/Resources/config/messenger.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/Resources/config/mongodb.php b/src/Resources/config/mongodb.php new file mode 100644 index 000000000..fcdc8ca8d --- /dev/null +++ b/src/Resources/config/mongodb.php @@ -0,0 +1,63 @@ + + * + * 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 FOS\ElasticaBundle\Doctrine\Listener; +use FOS\ElasticaBundle\Doctrine\MongoDB\ElasticaToModelTransformer; +use FOS\ElasticaBundle\Doctrine\MongoDBPagerProvider; +use FOS\ElasticaBundle\Doctrine\RegisterListenersService; +use FOS\ElasticaBundle\Doctrine\RepositoryManager; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.pager_provider.prototype.mongodb', MongoDBPagerProvider::class) + ->abstract() + ->args([ + service('doctrine_mongodb'), + service('fos_elastica.doctrine.register_listeners'), + abstract_arg('model'), + [], + ]) + ; + + $services->set('fos_elastica.doctrine.register_listeners', RegisterListenersService::class) + ->args([service('event_dispatcher')]) + ; + + $services->set('fos_elastica.listener.prototype.mongodb', Listener::class) + ->abstract() + ->args([ + abstract_arg('object persister'), + service('fos_elastica.indexable'), + [], + null, + ]) + ; + + $services->set('fos_elastica.elastica_to_model_transformer.prototype.mongodb', ElasticaToModelTransformer::class) + ->abstract() + ->args([ + service('doctrine_mongodb'), + abstract_arg('model'), + [], + ]) + ->call('setPropertyAccessor', [service('fos_elastica.property_accessor')]) + ; + + $services->set('fos_elastica.manager.mongodb', RepositoryManager::class) + ->args([ + service('doctrine_mongodb'), + service('fos_elastica.repository_manager'), + ]) + ; +}; diff --git a/src/Resources/config/mongodb.xml b/src/Resources/config/mongodb.xml deleted file mode 100644 index 6c735734e..000000000 --- a/src/Resources/config/mongodb.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - null - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/orm.php b/src/Resources/config/orm.php new file mode 100644 index 000000000..819ce008b --- /dev/null +++ b/src/Resources/config/orm.php @@ -0,0 +1,63 @@ + + * + * 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 FOS\ElasticaBundle\Doctrine\Listener; +use FOS\ElasticaBundle\Doctrine\ORM\ElasticaToModelTransformer; +use FOS\ElasticaBundle\Doctrine\ORMPagerProvider; +use FOS\ElasticaBundle\Doctrine\RegisterListenersService; +use FOS\ElasticaBundle\Doctrine\RepositoryManager; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.pager_provider.prototype.orm', ORMPagerProvider::class) + ->abstract() + ->args([ + service('doctrine'), + service('fos_elastica.doctrine.register_listeners'), + abstract_arg('model'), + [], + ]) + ; + + $services->set('fos_elastica.doctrine.register_listeners', RegisterListenersService::class) + ->args([service('event_dispatcher')]) + ; + + $services->set('fos_elastica.listener.prototype.orm', Listener::class) + ->abstract() + ->args([ + abstract_arg('object persister'), + service('fos_elastica.indexable'), + [], + null, + ]) + ; + + $services->set('fos_elastica.elastica_to_model_transformer.prototype.orm', ElasticaToModelTransformer::class) + ->abstract() + ->args([ + service('doctrine'), + abstract_arg('model'), + [], + ]) + ->call('setPropertyAccessor', [service('fos_elastica.property_accessor')]) + ; + + $services->set('fos_elastica.manager.orm', RepositoryManager::class) + ->args([ + service('doctrine'), + service('fos_elastica.repository_manager'), + ]) + ; +}; diff --git a/src/Resources/config/orm.xml b/src/Resources/config/orm.xml deleted file mode 100644 index 3d82542eb..000000000 --- a/src/Resources/config/orm.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - null - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/persister.php b/src/Resources/config/persister.php new file mode 100644 index 000000000..5b7ee7f5c --- /dev/null +++ b/src/Resources/config/persister.php @@ -0,0 +1,66 @@ + + * + * 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 FOS\ElasticaBundle\Persister\InPlacePagerPersister; +use FOS\ElasticaBundle\Persister\Listener\FilterObjectsListener; +use FOS\ElasticaBundle\Persister\ObjectPersister; +use FOS\ElasticaBundle\Persister\ObjectSerializerPersister; +use FOS\ElasticaBundle\Persister\PagerPersisterRegistry; +use FOS\ElasticaBundle\Persister\PersisterRegistry; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.in_place_pager_persister', InPlacePagerPersister::class) + ->args([ + service('fos_elastica.persister_registry'), + service('event_dispatcher'), + ]) + ->tag('fos_elastica.pager_persister', ['persisterName' => 'in_place']) + ; + + $services->set('fos_elastica.pager_persister_registry', PagerPersisterRegistry::class) + ->args([tagged_locator('fos_elastica.pager_persister', 'persisterName')]) + ; + + $services->set('fos_elastica.persister_registry', PersisterRegistry::class) + ->args([tagged_locator('fos_elastica.persister', 'index')]) + ; + + $services->set('fos_elastica.filter_objects_listener', FilterObjectsListener::class) + ->args([service('fos_elastica.indexable')]) + ->tag('kernel.event_subscriber') + ; + + $services->set('fos_elastica.object_persister', ObjectPersister::class) + ->abstract() + ->args([ + abstract_arg('index'), + abstract_arg('model to elastica transformer'), + abstract_arg('model'), + abstract_arg('properties mapping'), + abstract_arg('options'), + ]) + ; + + $services->set('fos_elastica.object_serializer_persister', ObjectSerializerPersister::class) + ->abstract() + ->args([ + abstract_arg('type'), + abstract_arg('model to elastica transformer'), + abstract_arg('model'), + abstract_arg('serializer'), + abstract_arg('options'), + ]) + ; +}; diff --git a/src/Resources/config/persister.xml b/src/Resources/config/persister.xml deleted file mode 100644 index 9b590943b..000000000 --- a/src/Resources/config/persister.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/phpcr.php b/src/Resources/config/phpcr.php new file mode 100644 index 000000000..3cf80cb80 --- /dev/null +++ b/src/Resources/config/phpcr.php @@ -0,0 +1,63 @@ + + * + * 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 FOS\ElasticaBundle\Doctrine\Listener; +use FOS\ElasticaBundle\Doctrine\PHPCR\ElasticaToModelTransformer; +use FOS\ElasticaBundle\Doctrine\PHPCRPagerProvider; +use FOS\ElasticaBundle\Doctrine\RegisterListenersService; +use FOS\ElasticaBundle\Doctrine\RepositoryManager; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.pager_provider.prototype.phpcr', PHPCRPagerProvider::class) + ->abstract() + ->args([ + service('doctrine_phpcr'), + service('fos_elastica.doctrine.register_listeners'), + abstract_arg('model'), + [], + ]) + ; + + $services->set('fos_elastica.doctrine.register_listeners', RegisterListenersService::class) + ->args([service('event_dispatcher')]) + ; + + $services->set('fos_elastica.listener.prototype.phpcr', Listener::class) + ->abstract() + ->args([ + abstract_arg('object persister'), + service('fos_elastica.indexable'), + [], + null, + ]) + ; + + $services->set('fos_elastica.elastica_to_model_transformer.prototype.phpcr', ElasticaToModelTransformer::class) + ->abstract() + ->args([ + service('doctrine_phpcr'), + abstract_arg('model'), + [], + ]) + ->call('setPropertyAccessor', [service('fos_elastica.property_accessor')]) + ; + + $services->set('fos_elastica.manager.phpcr', RepositoryManager::class) + ->args([ + service('doctrine_phpcr'), + service('fos_elastica.repository_manager'), + ]) + ; +}; diff --git a/src/Resources/config/phpcr.xml b/src/Resources/config/phpcr.xml deleted file mode 100644 index af6b07bb0..000000000 --- a/src/Resources/config/phpcr.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - null - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/provider.php b/src/Resources/config/provider.php new file mode 100644 index 000000000..ec9057268 --- /dev/null +++ b/src/Resources/config/provider.php @@ -0,0 +1,22 @@ + + * + * 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 FOS\ElasticaBundle\Provider\PagerProviderRegistry; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.pager_provider_registry', PagerProviderRegistry::class) + ->args([tagged_locator('fos_elastica.pager_provider', 'index')]) + ; +}; diff --git a/src/Resources/config/provider.xml b/src/Resources/config/provider.xml deleted file mode 100644 index 2701033c5..000000000 --- a/src/Resources/config/provider.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/src/Resources/config/serializer.php b/src/Resources/config/serializer.php new file mode 100644 index 000000000..f3c02838e --- /dev/null +++ b/src/Resources/config/serializer.php @@ -0,0 +1,21 @@ + + * + * 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; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.serializer_callback_prototype') + ->abstract() + ->call('setSerializer', [service('fos_elastica.serializer')]) + ; +}; diff --git a/src/Resources/config/serializer.xml b/src/Resources/config/serializer.xml deleted file mode 100644 index e0374c65a..000000000 --- a/src/Resources/config/serializer.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Resources/config/source.php b/src/Resources/config/source.php new file mode 100644 index 000000000..19cb2fe76 --- /dev/null +++ b/src/Resources/config/source.php @@ -0,0 +1,29 @@ + + * + * 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 FOS\ElasticaBundle\Configuration\Source\ContainerSource; +use FOS\ElasticaBundle\Configuration\Source\TemplateContainerSource; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.config_source.container', ContainerSource::class) + ->args([[]]) + ->tag('fos_elastica.config_source') + ; + + $services->set('fos_elastica.config_source.template_container', TemplateContainerSource::class) + ->args([[]]) + ->tag('fos_elastica.config_source', ['source' => 'index_template']) + ; +}; diff --git a/src/Resources/config/source.xml b/src/Resources/config/source.xml deleted file mode 100644 index ea1138481..000000000 --- a/src/Resources/config/source.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/transformer.php b/src/Resources/config/transformer.php new file mode 100644 index 000000000..3e728d60e --- /dev/null +++ b/src/Resources/config/transformer.php @@ -0,0 +1,34 @@ + + * + * 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 FOS\ElasticaBundle\Transformer\ModelToElasticaAutoTransformer; +use FOS\ElasticaBundle\Transformer\ModelToElasticaIdentifierTransformer; + +return static function (ContainerConfigurator $container): void { + $services = $container->services(); + + $services->set('fos_elastica.model_to_elastica_transformer', ModelToElasticaAutoTransformer::class) + ->abstract() + ->args([ + [], + service('event_dispatcher'), + ]) + ->call('setPropertyAccessor', [service('fos_elastica.property_accessor')]) + ; + + $services->set('fos_elastica.model_to_elastica_identifier_transformer', ModelToElasticaIdentifierTransformer::class) + ->abstract() + ->args([[]]) + ->call('setPropertyAccessor', [service('fos_elastica.property_accessor')]) + ; +}; diff --git a/src/Resources/config/transformer.xml b/src/Resources/config/transformer.xml deleted file mode 100644 index 941e553bf..000000000 --- a/src/Resources/config/transformer.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -