parameters:
    kunstmaan_node_search.search_configuration.node.class: Kunstmaan\NodeSearchBundle\Configuration\NodePagesConfiguration
    kunstmaan_node_search.search_configuration.number_of_shards: 1
    kunstmaan_node_search.search_configuration.number_of_replicas: 0
    kunstmaan_node_search.indexname: 'nodeindex'
    kunstmaan_node_search.indextype: 'page'
    kunstmaan_node_search.search.node.class: Kunstmaan\NodeSearchBundle\Search\NodeSearcher
    kunstmaan_node_search.search_service.class: Kunstmaan\NodeSearchBundle\Services\SearchService

services:
    # Autowire aliases
    Kunstmaan\NodeSearchBundle\Services\SearchService: '@kunstmaan_node_search.search.service'
    Kunstmaan\NodeSearchBundle\Search\NodeSearcher: '@kunstmaan_node_search.search.node'

    kunstmaan_node_search.search.abstract_elastica_searcher:
        class: Kunstmaan\NodeSearchBundle\Search\AbstractElasticaSearcher
        abstract: true
        calls:
            - [ setSearch, ['@kunstmaan_search.search']]

    kunstmaan_node_search.search.node:
        class: "%kunstmaan_node_search.search.node.class%"
        parent: kunstmaan_node_search.search.abstract_elastica_searcher
        calls:
            - [ setIndexName, ['%kunstmaan_node_search.indexname%']]
            - [ setTokenStorage, ['@security.token_storage']]
            - [ setDomainConfiguration, ['@kunstmaan_admin.domain_configuration']]
            - [ setEntityManager, ['@doctrine.orm.entity_manager']]
        tags:
            - { name: kunstmaan_node_search.node_searcher }

    kunstmaan_node_search.service.indexable_pageparts:
        class: Kunstmaan\NodeSearchBundle\Helper\IndexablePagePartsService
        arguments:
            - '@doctrine.orm.entity_manager'
            - '%kunstmaan_node_search.contexts%'

    kunstmaan_node_search.twig.extension:
        class: Kunstmaan\NodeSearchBundle\Twig\KunstmaanNodeSearchTwigExtension
        arguments: ['@doctrine.orm.entity_manager', '@kunstmaan_node_search.service.indexable_pageparts']
        tags:
            - { name: twig.extension }

    kunstmaan_node_search.search_configuration.node:
        class: "%kunstmaan_node_search.search_configuration.node.class%"
        arguments: ['@service_container', '@kunstmaan_search.search', '%kunstmaan_node_search.indexname%', '%kunstmaan_node_search.indextype%', '%kunstmaan_node_search.search_configuration.number_of_shards%', '%kunstmaan_node_search.search_configuration.number_of_replicas%']
        calls:
            - [ setAclProvider, ['@security.acl.provider']]
            - [ setIndexablePagePartsService, ['@kunstmaan_node_search.service.indexable_pageparts']]
        tags:
            - { name: kunstmaan_search.search_configuration, alias: Node }

    kunstmaan_node_search.search.service:
        class: "%kunstmaan_node_search.search_service.class%"
        arguments:
            - '@service_container'
            - '@request_stack'
            - 10
            - ~ #Will be replace by the NodeSearcherCompilerPass
        public: true

    Kunstmaan\NodeSearchBundle\Services\SearchViewRenderer:
        arguments:
            - '@twig'
            - '@kunstmaan_node_search.service.indexable_pageparts'
            - '@request_stack'

    # Public alias for BC reasons in NodePagesConfiguration class.
    # To be deprecated after a refactor of the NodePagesConfiguration class.
    kunstmaan_node_search.service.search_view_renderer:
        alias: Kunstmaan\NodeSearchBundle\Services\SearchViewRenderer
        public: true
