parameters:
    kunstmaan_pagepart.page_part_configuration_reader.class: 'Kunstmaan\PagePartBundle\PagePartConfigurationReader\PagePartConfigurationReader'
    kunstmaan_pagepart.page_part_configuration_parser.class: 'Kunstmaan\PagePartBundle\PagePartConfigurationReader\PagePartConfigurationParser'

    kunstmaan_pagepart.page_template_configuration_reader.class: 'Kunstmaan\PagePartBundle\PageTemplate\PageTemplateConfigurationReader'
    kunstmaan_pagepart.page_template_configuration_parser.class: 'Kunstmaan\PagePartBundle\PageTemplate\PageTemplateConfigurationParser'

    kunstmaan_page_part.page_template.page_template_configuration_service.class: 'Kunstmaan\PagePartBundle\PageTemplate\PageTemplateConfigurationService'

services:
    kunstmaan_pagepart.pageparts:
        class: 'Kunstmaan\PagePartBundle\PagePartAdmin\Builder'

    kunstmaan_page_part.page_part_configuration_reader:
        class: '%kunstmaan_pagepart.page_part_configuration_reader.class%'
        arguments: [ '@kunstmaan_page_part.page_part_configuration_parser' ]
        public: true

    kunstmaan_page_part.page_part_configuration_parser:
        class: '%kunstmaan_pagepart.page_part_configuration_parser.class%'
        public: false
        arguments: [ '@kernel', '%kunstmaan_page_part.page_parts_presets%' ]

    kunstmaan_page_part.page_template_configuration_reader:
        class: '%kunstmaan_pagepart.page_template_configuration_reader.class%'
        arguments: [ '@kunstmaan_page_part.page_template_configuration_parser' ]

    kunstmaan_page_part.page_template_configuration_parser:
        class: '%kunstmaan_pagepart.page_template_configuration_parser.class%'
        public: false
        arguments: [ '@kernel', '%kunstmaan_page_part.page_templates_presets%' ]


    kunstmaan_page_part.page_template.page_template_configuration_service:
        class: '%kunstmaan_page_part.page_template.page_template_configuration_service.class%'
        arguments:
          - '@kunstmaan_page_part.repository.page_template_configuration'
          - '@kunstmaan_page_part.page_template_configuration_reader'

    kunstmaan_page_part.repository.page_template_configuration:
        class: 'Kunstmaan\PagePartBundle\Repository\PageTemplateConfigurationRepository'
        public: false
        factory: [ '@doctrine.orm.entity_manager', 'getRepository' ]
        arguments:
          - 'KunstmaanPagePartBundle:PageTemplateConfiguration'

    kunstmaan_pagepartadmin.factory:
        class: 'Kunstmaan\PagePartBundle\PagePartAdmin\PagePartAdminFactory'
        arguments: ['@service_container']

    kunstmaan_pagepartadmin.twig.extension:
        class: 'Kunstmaan\PagePartBundle\Twig\Extension\PagePartAdminTwigExtension'
        tags:
            -  { name: twig.extension }
        calls:
            - [ setUsesExtendedPagePartChooser, [ '%kunstmaan_page_part.extended%' ] ]

    kunstmaan_pageparts.twig.extension:
        class: 'Kunstmaan\PagePartBundle\Twig\Extension\PagePartTwigExtension'
        arguments:
            - '@doctrine.orm.entity_manager'
        tags:
            - { name: twig.extension }

    kunstmaan_pagetemplate.twig.extension:
        class: 'Kunstmaan\PagePartBundle\Twig\Extension\PageTemplateTwigExtension'
        arguments:
            - '@kunstmaan_page_part.page_template.page_template_configuration_service'
        tags:
            - { name: twig.extension }

    kunstmaan_pageparts.pagepart_creator_service:
        class: 'Kunstmaan\PagePartBundle\Helper\Services\PagePartCreatorService'
        calls:
            - [ setEntityManager, [ '@doctrine.orm.entity_manager' ] ]
        public: true

    kunstmaan_pageparts.edit_node.listener:
        class: 'Kunstmaan\PagePartBundle\EventListener\NodeListener'
        arguments:
          - '@doctrine.orm.entity_manager'
          - '@kunstmaan_pagepartadmin.factory'
          - '@kunstmaan_page_part.page_template_configuration_reader'
          - '@kunstmaan_page_part.page_part_configuration_reader'
          - '@kunstmaan_page_part.page_template.page_template_configuration_service'
        tags:
            - { name: kernel.event_listener, event: kunstmaan_node.adaptForm, method: adaptForm }

    kunstmaan_pageparts.clone.listener:
        class: 'Kunstmaan\PagePartBundle\EventListener\CloneListener'
        arguments:
          - '@doctrine.orm.entity_manager'
          - '@kunstmaan_page_part.page_part_configuration_reader'
          - '@kunstmaan_page_part.page_template.page_template_configuration_service'

        tags:
            - { name: kernel.event_listener, event: kunstmaan_admin.postDeepCloneAndSave, method: postDeepCloneAndSave }
