parameters:
    matthias_symfony_console_form.cache_directory: "%kernel.cache_dir%/matthias_symfony_console_form"

services:
    console_form_helper:
        alias: matthias_symfony_console_form.form_helper

    matthias_symfony_console_form.form_helper:
        class: Matthias\SymfonyConsoleForm\Console\Helper\FormHelper
        public: false
        arguments:
            - "@matthias_symfony_console_form.console_form_factory"
            - "@matthias_symfony_console_form.delegating_interactor"
        tags:
            - { name: console_helper }

    matthias_symfony_console_form.input_definition_factory:
        class: Matthias\SymfonyConsoleForm\Console\Input\CachedInputDefinitionFactory
        public: false
        arguments:
            - "@matthias_symfony_console_form.real_input_definition_factory"
            - "%matthias_symfony_console_form.cache_directory%"
            - "%kernel.debug%"

    matthias_symfony_console_form.real_input_definition_factory:
        class: Matthias\SymfonyConsoleForm\Console\Input\FormBasedInputDefinitionFactory
        public: false
        arguments:
            - "@form.factory"

    matthias_symfony_console_form.abstract_transformer:
        abstract:  true
        arguments: [ "@translator" ]

    matthias_symfony_console_form.text_transformer:
        class: Matthias\SymfonyConsoleForm\Bridge\Transformer\TextTransformer
        parent: matthias_symfony_console_form.abstract_transformer
        public: false
        tags:
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\TextType }

    matthias_symfony_console_form.integer_transformer:
        class: Matthias\SymfonyConsoleForm\Bridge\Transformer\IntegerTransformer
        parent: matthias_symfony_console_form.abstract_transformer
        public: false
        tags:
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\IntegerType }

    matthias_symfony_console_form.number_transformer:
        class: Matthias\SymfonyConsoleForm\Bridge\Transformer\NumberTransformer
        parent: matthias_symfony_console_form.abstract_transformer
        public: false
        tags:
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\NumberType }

    matthias_symfony_console_form.date_time_transformer:
        class: Matthias\SymfonyConsoleForm\Bridge\Transformer\DateTimeTransformer
        parent: matthias_symfony_console_form.abstract_transformer
        public: false
        tags:
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\TimeType }
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\DateType }
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\DateTimeType }

    matthias_symfony_console_form.password_transformer:
        class: Matthias\SymfonyConsoleForm\Bridge\Transformer\PasswordTransformer
        parent: matthias_symfony_console_form.abstract_transformer
        public: false
        tags:
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\PasswordType }

    matthias_symfony_console_form.choice_transformer:
        class: Matthias\SymfonyConsoleForm\Bridge\Transformer\ChoiceTransformer
        parent: matthias_symfony_console_form.abstract_transformer
        public: false
        tags:
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\ChoiceType }
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\CountryType }

    matthias_symfony_console_form.checkbox_transformer:
        class: Matthias\SymfonyConsoleForm\Bridge\Transformer\CheckboxTransformer
        parent: matthias_symfony_console_form.abstract_transformer
        public: false
        tags:
            - { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\CheckboxType }

    matthias_symfony_console_form.delegating_interactor:
        class: Matthias\SymfonyConsoleForm\Bridge\Interaction\DelegatingInteractor
        public: false
        calls:
            # more specific interactors (by form type acenstry) should be higher in this list
            - [addInteractor, ["@matthias_symfony_console_form.field_with_no_interaction_interactor"]]
            - [addInteractor, ["@matthias_symfony_console_form.non_interactive_root_interactor"]]
            - [addInteractor, ["@matthias_symfony_console_form.collection_interactor"]]
            - [addInteractor, ["@matthias_symfony_console_form.compound_interactor"]]
            - [addInteractor, ["@matthias_symfony_console_form.field_interactor"]]

    matthias_symfony_console_form.compound_interactor:
        class: Matthias\SymfonyConsoleForm\Bridge\Interaction\CompoundInteractor
        public: false
        arguments:
            - "@matthias_symfony_console_form.delegating_interactor"

    matthias_symfony_console_form.field_with_no_interaction_interactor:
        class: Matthias\SymfonyConsoleForm\Bridge\Interaction\FieldWithNoInteractionInteractor
        public: false

    matthias_symfony_console_form.non_interactive_root_interactor:
        class: Matthias\SymfonyConsoleForm\Bridge\Interaction\NonInteractiveRootInteractor
        public: false
        arguments:
            - "@matthias_symfony_console_form.delegating_interactor"

    matthias_symfony_console_form.collection_interactor:
        class: Matthias\SymfonyConsoleForm\Bridge\Interaction\CollectionInteractor
        public: false
        arguments:
            - "@matthias_symfony_console_form.delegating_interactor"

    matthias_symfony_console_form.field_interactor:
        class: Matthias\SymfonyConsoleForm\Bridge\Interaction\FieldInteractor
        public: false
        arguments:
            - "@matthias_symfony_console.transformer_resolver"

    matthias_symfony_console.transformer_resolver:
        class: Matthias\SymfonyConsoleForm\Bridge\Transformer\TypeAncestryBasedTransformerResolver
        public: false

    matthias_symfony_console_form.handle_form_based_command_event_listener:
        class: Matthias\SymfonyConsoleForm\Console\EventListener\HandleFormBasedCommandEventListener
        public: true
        arguments:
            - "@matthias_symfony_console_form.form_helper"
        tags:
            - { name: kernel.event_listener, event: console.command, method: onConsoleCommand, priority: 200 }

    matthias_symfony_console_form.set_input_definition_of_form_based_command_event_listener:
        class: Matthias\SymfonyConsoleForm\Console\EventListener\SetInputDefinitionOfFormBasedCommandEventListener
        public: true
        arguments:
            - "@matthias_symfony_console_form.input_definition_factory"
        tags:
            - { name: kernel.event_listener, event: console.command, method: onConsoleCommand, priority: 2000 }

    matthias_symfony_console_form.console_form_type_extension:
        class: Matthias\SymfonyConsoleForm\Form\ConsoleFormTypeExtension
        public: true
        tags:
            - { name: form.type_extension, alias: form, extended_type: Symfony\Component\Form\Extension\Core\Type\FormType }

    matthias_symfony_console_form.console_form_factory:
        class: Matthias\SymfonyConsoleForm\Bridge\FormFactory\ConsoleFormWithDefaultValuesAndOptionsFactory
        public: false
        arguments:
            - "@form.factory"
            - "@form.registry"
