parameters:
    oro_search.index.class:                               Oro\Bundle\SearchBundle\Engine\Indexer
    oro_search.security_provider.class:                   Oro\Bundle\SearchBundle\Security\SecurityProvider
    oro_search.index_listener.class:                      Oro\Bundle\SearchBundle\EventListener\IndexListener
    oro_search.twig_extension.class:                      Oro\Bundle\SearchBundle\Twig\OroSearchExtension
    oro_search.mapper.class:                              Oro\Bundle\SearchBundle\Engine\ObjectMapper
    oro_search.provider.result_statistics_provider.class: Oro\Bundle\SearchBundle\Provider\ResultStatisticsProvider
    oro_search.formatter.result_formatter.class:          Oro\Bundle\SearchBundle\Formatter\ResultFormatter
    oro_search.prepare_result_item.listener.class:        Oro\Bundle\SearchBundle\EventListener\PrepareResultItemListener

    oro_search.extension.formatter.property.search_result_property.class: Oro\Bundle\SearchBundle\Extension\SearchResultProperty
    oro_search.extension.search_results.class:                            Oro\Bundle\SearchBundle\Extension\SearchResultsExtension

    oro_search.event_listener.search_results_grid_listener.class: Oro\Bundle\SearchBundle\EventListener\SearchResultsGridListener
    oro_search.event_listener.demo_data_listener.class:           Oro\Bundle\SearchBundle\EventListener\DemoDataMigrationListener
    oro_search.datasource.search.class:                           Oro\Bundle\SearchBundle\Extension\SearchDatasource

    oro_search.extension.orm_pager.class:          Oro\Bundle\SearchBundle\Extension\Pager\SearchPagerExtension
    oro_search.extension.pager.search.pager.class: Oro\Bundle\SearchBundle\Extension\Pager\IndexerPager

    # services used only for ORM search engine
    oro_search.fulltext_index_manager.class:                      Oro\Bundle\SearchBundle\Engine\FulltextIndexManager
    oro_search.event_listener.update_schema_listener.class:       Oro\Bundle\SearchBundle\EventListener\UpdateSchemaDoctrineListener
    oro_search.event_listener.orm.fulltext_index_listener.class:  Oro\Bundle\SearchBundle\EventListener\ORM\FulltextIndexListener

    oro_search.drivers:
        pdo_mysql: Oro\Bundle\SearchBundle\Engine\Orm\PdoMysql
        pdo_pgsql: Oro\Bundle\SearchBundle\Engine\Orm\PdoPgsql

services:
    oro_search.index:
        class:                        %oro_search.index.class%
        arguments:
            - "@doctrine.orm.entity_manager"
            - "@oro_search.search.engine"
            - "@oro_search.mapper"
            - "@oro_search.security_provider"

    oro_search.security_provider:
        class:                        %oro_search.security_provider.class%
        public:                       false
        arguments:
            - "@oro_security.security_facade"
            - "@oro_security.entity_security_metadata_provider"

    oro_search.index_listener:
        class:                        %oro_search.index_listener.class%
        arguments:
            - @oro_entity.doctrine_helper
            - @oro_search.search.engine
        calls:
            - [setRealTimeUpdate, [%oro_search.realtime_update%]]
            - [setEntitiesConfig, [%oro_search.entities_config%]]
        tags:
            - { name: doctrine.event_listener, event: onFlush }
            - { name: doctrine.event_listener, event: postFlush }
            - { name: doctrine.event_listener, event: onClear }

    oro_search.twig.search_extension:
        class:                        %oro_search.twig_extension.class%
        tags:
            - { name: twig.extension }

    oro_search.mapper:
        class:                        %oro_search.mapper.class%
        arguments:                    [@event_dispatcher, %oro_search.entities_config%]

    oro_search.provider.result_statistics_provider:
        class:                        %oro_search.provider.result_statistics_provider.class%
        arguments:
            - @oro_search.index
            - @oro_entity_config.config_manager
            - @translator
        lazy: true

    oro_search.formatter.result_formatter:
        class:                        %oro_search.formatter.result_formatter.class%
        arguments:                    ["@doctrine.orm.entity_manager"]

    oro_search.prepare_result_item.listener:
        class:                        %oro_search.prepare_result_item.listener.class%
        arguments:
            - @router
            - @oro_search.mapper
            - @doctrine.orm.entity_manager
        tags:
            - { name: kernel.event_listener, event: oro_search.prepare_result_item, method: process }

    oro_search.extension.formatter.property.search_result_property:
        class: %oro_search.extension.formatter.property.search_result_property.class%
        arguments:
            - @twig
            - %oro_search.entities_config%
        tags:
            - { name:  oro_datagrid.extension.formatter.property, type: search-result }

    oro_search.extension.search_results:
        class: %oro_search.extension.search_results.class%
        arguments:
            - @oro_search.formatter.result_formatter
            - @doctrine.orm.entity_manager
            - @oro_search.mapper
            - @event_dispatcher
        tags:
            - { name: oro_datagrid.extension }

    oro_search.event_listener.search_results_grid_listener:
        class: %oro_search.event_listener.search_results_grid_listener.class%
        tags:
          - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.search-grid, method: onBuildAfter }

    oro_search.datasource.search:
        class: %oro_search.datasource.search.class%
        arguments:
            - @oro_search.index
        tags:
            - { name: oro_datagrid.datasource, type: search }

    oro_search.extension.pager.orm.pager:
        class: %oro_search.extension.pager.search.pager.class%

    oro_search.extension.search_pager:
        class: %oro_search.extension.orm_pager.class%
        arguments:
            - @oro_search.extension.pager.orm.pager
        tags:
            - { name: oro_datagrid.extension }

    # services used only for ORM search engine
    oro_search.fulltext_index_manager:
        class: %oro_search.fulltext_index_manager.class%
        arguments:
            - @doctrine.dbal.default_connection
            - %oro_search.drivers%

    oro_search.event_listener.update_schema_listener:
        class: %oro_search.event_listener.update_schema_listener.class%
        arguments:
            - @oro_search.fulltext_index_manager
            - @service_container
        tags:
            - { name: kernel.event_listener, event: console.terminate }

    oro_search.event_listener.demo_data_listener:
        class: %oro_search.event_listener.demo_data_listener.class%
        arguments:
            - @oro_search.search.engine
            - @oro_search.index_listener
        tags:
            - { name: kernel.event_listener, event: console.command, method: onConsoleCommand }
            - { name: kernel.event_listener, event: console.terminate, method: onConsoleTerminate }

    oro_search.event_listener.orm.fulltext_index_listener:
        class: %oro_search.event_listener.orm.fulltext_index_listener.class%
        arguments:
            - %database_driver%
        tags:
            - { name: doctrine.event_listener, event: loadClassMetadata }
