parameters:
    kunstmaan_node.version_timeout: 3600
    kunstmaan_node.slugrouter.class: 'Kunstmaan\NodeBundle\Router\SlugRouter'
    kunstmaan_node.sluglistener.class: 'Kunstmaan\NodeBundle\EventListener\SlugListener'
    kunstmaan_node.helper.url.class: Kunstmaan\NodeBundle\Helper\URLHelper
    kunstmaan_node.url_replace.twig.class: Kunstmaan\NodeBundle\Twig\UrlReplaceTwigExtension
    kunstmaan_node.url_chooser.lazy_increment: 2
    kunstmaan_multi_domain.url_replace.controller.class: Kunstmaan\NodeBundle\Controller\UrlReplaceController
    kunstmaan_node.toolbar.collector.node.class: Kunstmaan\NodeBundle\Toolbar\NodeDataCollector

services:
    # Autowire aliases
    Kunstmaan\NodeBundle\Helper\Services\PageCreatorService: '@kunstmaan_node.page_creator_service'
    Kunstmaan\NodeBundle\Helper\NodeMenu: '@kunstmaan_node.node_menu'

    kunstmaan_node.nodetranslation.listener:
        class: Kunstmaan\NodeBundle\EventListener\NodeTranslationListener
        arguments:
          - '@session'
          - '@kunstmaan_admin.logger'
          - '@kunstmaan_utilities.slugifier'
          - '@request_stack'
          - '@kunstmaan_admin.domain_configuration'
          - '@kunstmaan_node.pages_configuration'
        tags:
            - { name: 'doctrine.event_listener', event: 'onFlush', method: 'onFlush' }
            - { name: 'doctrine.event_listener', event: 'prePersist', method: 'prePersist' }
            - { name: 'doctrine.event_listener', event: 'preUpdate', method: 'preUpdate' }

    kunstmaan_node.node_tabs.listener:
        class: Kunstmaan\NodeBundle\EventListener\NodeTabListener
        tags:
            - { name: kernel.event_listener, event: kunstmaan_node.adaptForm, method: adaptForm }

    kunstmaan_node.entity_tabs.listener:
        class: Kunstmaan\NodeBundle\EventListener\EntityTabListener
        arguments:
            - '@request_stack'
            - '@form.factory'
        tags:
            - { name: kernel.event_listener, event: kunstmaan_admin.adaptSimpleForm, method: adaptForm }

    kunstmaan_node.menu.adaptor.pages:
        class: Kunstmaan\NodeBundle\Helper\Menu\PageMenuAdaptor
        arguments: ['@doctrine.orm.entity_manager', '@kunstmaan_admin.acl.native.helper', '@kunstmaan_node.pages_configuration', '@kunstmaan_admin.domain_configuration']
        tags:
            -  { name: 'kunstmaan_admin.menu.adaptor', priority: 250 }

    Kunstmaan\NodeBundle\Helper\PageCloningHelper:
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@kunstmaan_admin.clone.helper'
            - '@security.acl.provider'
            - '@security.acl.object_identity_retrieval_strategy'
            - '@security.authorization_checker'
            - '@event_dispatcher'
        public: true

    kunstmaan_node.form.type.urlchooser:
        class: Kunstmaan\NodeBundle\Form\Type\URLChooserType
        tags:
            - { name: 'form.type' }

    kunstmaan_node.form.type.slug:
        class: Kunstmaan\NodeBundle\Form\Type\SlugType
        arguments: ['@kunstmaan_utilities.slugifier']
        tags:
            - { name: 'form.type' }

    kunstmaan_node.form.type.nodechoice:
        class: Kunstmaan\NodeBundle\Form\NodeChoiceType
        arguments:
            - "@request_stack"
        tags:
            - { name: form.type }

    kunstmaan_node.admin_node.publisher:
        class: Kunstmaan\NodeBundle\Helper\NodeAdmin\NodeAdminPublisher
        public: true
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@security.token_storage'
            - '@security.authorization_checker'
            - '@event_dispatcher'
            - '@kunstmaan_admin.clone.helper'

    kunstmaan_node.admin_node.node_version_lock_helper:
        class: Kunstmaan\NodeBundle\Helper\NodeAdmin\NodeVersionLockHelper
        arguments: ['@service_container', '@doctrine.orm.entity_manager']
        public: true

    kunstmaan_node.actions_menu_builder:
        class: Kunstmaan\NodeBundle\Helper\Menu\ActionsMenuBuilder
        arguments:
            - '@knp_menu.factory'
            - '@doctrine.orm.entity_manager'
            - '@router'
            - '@event_dispatcher'
            - '@security.authorization_checker'
            - '@kunstmaan_node.pages_configuration'
            - '%kunstmaan_node.enable_export_page_template%'
            - '%kunstmaan_node.show_duplicate_with_children%'
        public: true

    kunstmaan_node.menu.sub_actions:
        class: Knp\Menu\MenuItem # the service definition requires setting the class
        factory: ['@kunstmaan_node.actions_menu_builder', createSubActionsMenu]
        tags:
            - { name: 'knp_menu.menu', alias: 'sub_actions' } # The alias is what is used to retrieve the menu

    kunstmaan_node.menu.actions:
        class: Knp\Menu\MenuItem # the service definition requires setting the class
        factory: ['@kunstmaan_node.actions_menu_builder', createActionsMenu]
        tags:
            - { name: 'knp_menu.menu', alias: 'actions' } # The alias is what is used to retrieve the menu

    kunstmaan_node.menu.top_actions:
        class: Knp\Menu\MenuItem # the service definition requires setting the class
        factory: ['@kunstmaan_node.actions_menu_builder', createTopActionsMenu]
        tags:
            - { name: 'knp_menu.menu', alias: 'top_actions' } # The alias is what is used to retrieve the menu

    kunstmaan_node.fix_date.listener:
        class: Kunstmaan\NodeBundle\EventListener\FixDateListener
        tags:
            - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse, priority: -100 }

    kunstmaan_node.edit_node.listener:
        class: Kunstmaan\NodeBundle\EventListener\NodeListener
        arguments:
            - '@security.authorization_checker'
            - '@kunstmaan_admin.permissionadmin'
            - '@kunstmaan_admin.security.acl.permission.map'
            - '%kunstmaan_node.permissions.enabled%'
        tags:
            - { name: kernel.event_listener, event: kunstmaan_node.adaptForm, method: adaptForm }

    kunstmaan_node.log_page_events.subscriber:
        class: Kunstmaan\NodeBundle\EventListener\LogPageEventsSubscriber
        arguments: ['@kunstmaan_admin.logger', '@security.token_storage']
        tags:
            - { name: kernel.event_subscriber }

    kunstmaan_node.slugrouter:
        class: '%kunstmaan_node.slugrouter.class%'
        arguments:
            - '@kunstmaan_admin.domain_configuration'
            - '@request_stack'
            - '@doctrine.orm.entity_manager'
            - '%kunstmaan_admin.admin_prefix%'
        tags:
            - { name: router, priority: 0 }

    kunstmaan_node.pages_configuration.twig_extension:
        class: Kunstmaan\NodeBundle\Twig\PagesConfigurationTwigExtension
        public: false
        arguments: [ '@kunstmaan_node.pages_configuration' ]
        tags:
            - { name: twig.extension }

    kunstmaan_node.url_replace.twig.extension:
        class: "%kunstmaan_node.url_replace.twig.class%"
        arguments:
            - "@kunstmaan_node.helper.url"
        tags:
            - { name: twig.extension }

    kunstmaan_node.page_creator_service:
        class: Kunstmaan\NodeBundle\Helper\Services\PageCreatorService
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@kunstmaan_node.acl_permission_creator_service'
            - '%fos_user.model.user.class%'
        public: true

    kunstmaan_node.acl_permission_creator_service:
        class: Kunstmaan\NodeBundle\Helper\Services\ACLPermissionCreatorService
        arguments:
            - '@security.acl.provider'
            - '@security.acl.object_identity_retrieval_strategy'
        public: true

    kunstmaan_node.doctrine_mapping.listener:
        class: Kunstmaan\NodeBundle\EventListener\MappingListener
        arguments: ['%fos_user.model.user.class%']
        tags:
            - { name: doctrine.event_listener, event: loadClassMetadata }

    kunstmaan_node.slug.listener:
        class: '%kunstmaan_node.sluglistener.class%'
        arguments: ['@doctrine.orm.entity_manager','@controller_resolver', '@event_dispatcher']
        tags:
            - { name: kernel.event_listener, event: kernel.controller, method: onKernelController }

    kunstmaan_node.slug.security.listener:
        class: Kunstmaan\NodeBundle\EventListener\SlugSecurityListener
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@security.authorization_checker'
            - '@kunstmaan_node.node_menu'
            - '%kunstmaan_node.permissions.enabled%'
        tags:
            - { name: kernel.event_listener, event: kunstmaan_node.slug.security, method: onSlugSecurityEvent }

    kunstmaan_node.render.context.listener:
        class: Kunstmaan\NodeBundle\EventListener\RenderContextListener
        arguments: ['@doctrine.orm.entity_manager']
        tags:
            - { name: kernel.event_listener, event: kernel.view, method: onKernelView }

    kunstmaan_node.node_menu:
        class: Kunstmaan\NodeBundle\Helper\NodeMenu
        arguments: ['@doctrine.orm.entity_manager', '@security.token_storage', '@kunstmaan_admin.acl.helper', '@kunstmaan_admin.domain_configuration']
        public: true

    kunstmaan_node.node.twig.extension:
        class: Kunstmaan\NodeBundle\Twig\NodeTwigExtension
        arguments: ['@doctrine.orm.entity_manager', '@router', '@kunstmaan_node.node_menu', '@request_stack']
        tags:
            - { name: twig.extension }

    kunstmaan_node.helper.url:
        class: "%kunstmaan_node.helper.url.class%"
        arguments:
            - "@doctrine.orm.entity_manager"
            - "@router"
            - "@logger"
            - "@kunstmaan_admin.domain_configuration"

    kunstmaan_node.url_replace.controller:
        class: "%kunstmaan_multi_domain.url_replace.controller.class%"
        arguments:
            - "@kunstmaan_node.helper.url"
        public: true

    # Add service alias to use controller as a service with the symfony core route annotation
    Kunstmaan\NodeBundle\Controller\UrlReplaceController: '@kunstmaan_node.url_replace.controller'

    kunstmaan_node.helper.node:
        class: Kunstmaan\NodeBundle\Helper\NodeHelper
        arguments:
            - "@doctrine.orm.entity_manager"
            - "@kunstmaan_node.admin_node.publisher"
            - "@security.token_storage"
            - "@kunstmaan_admin.clone.helper"
            - "@event_dispatcher"

    ### TOOLBAR DATA COLLECTOR ###
    kunstmaan_node.datacollector.node:
        class: '%kunstmaan_node.toolbar.collector.node.class%'
        parent: Kunstmaan\AdminBundle\Helper\Toolbar\AbstractDataCollector
        arguments:
            - '@kunstmaan_node.node_menu'
            - '@router'
        tags:
            - { name: kunstmaan_admin.toolbar_collector, template: '@KunstmaanNode/Toolbar/node.html.twig', id: kuma_node}
