services:
    gedmo.listener.translatable:
        class: Gedmo\Translatable\TranslatableListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ @annotation_reader ] ]
            - [ setDefaultLocale, [ 'en_US' ] ]
            - [ setTranslationFallback, [ true ] ]
    # KernelRequest listener
    extension.listener:
        class: Twtools\LocaleBundle\Listener\LocaleListener
        calls:
            - [ setContainer, [ @service_container ] ]
        tags:
            # translatable sets locale after router processing
            - { name: kernel.event_listener, event: kernel.request, method: onLateKernelRequest, priority: -10 }
            # loggable hooks user username if one is in security context
            #- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
    form.type.languagetype:
        class: Twtools\LocaleBundle\Form\Type\LanguageType
        tags:
            - { name: form.type, alias: twlocale }
        calls:
            - [ setContainer, [ @service_container ] ]
    form.type.countrytype:
        class: Twtools\LocaleBundle\Form\Type\CountryType
        tags:
            - { name: form.type, alias: twcountry }
        calls:
            - [ setContainer, [ @service_container, @translator ] ]
    country.twig.extension:
        class:  Twtools\LocaleBundle\Twig\Extension\TwtoolsTwigExtensionsCountry
        arguments: [@service_container, @translator]
        tags:   [ { name: 'twig.extension' } ]