services:
    Oro\Bundle\ContactBundle\Form\Type\ContactType:
        alias: oro_contact.form.contact

    oro_contact.form.contact:
        class: Symfony\Component\Form\Form
        public: true
        factory: ['@form.factory', createNamed]
        arguments: ["oro_contact_form", Oro\Bundle\ContactBundle\Form\Type\ContactType, null]

    oro_contact.form.group:
        class: Symfony\Component\Form\Form
        public: true
        factory: ['@form.factory', createNamed]
        arguments: ["oro_contact_group_form", Oro\Bundle\ContactBundle\Form\Type\GroupType]

    oro_contact.form.type.contact:
        class: Oro\Bundle\ContactBundle\Form\Type\ContactType
        arguments:
            - 'Oro\Bundle\ContactBundle\Entity\Contact'
            - 'Oro\Bundle\ContactBundle\Entity\ContactAddress'
        tags:
            - { name: form.type, alias: oro_contact }

    oro_contact.form.handler.contact:
        class: Oro\Bundle\ContactBundle\Form\Handler\ContactHandler
        public: true
        arguments:
            - "@doctrine.orm.entity_manager"

    oro_contact.contact.manager:
        class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\ContactBundle\Entity\Contact'
            - "@doctrine.orm.entity_manager"

    oro_contact.form.type.contact_select:
        class: Oro\Bundle\ContactBundle\Form\Type\ContactSelectType
        tags:
            - { name: form.type, alias: oro_contact_select }

    oro_contact.form.handler.group:
        class: Oro\Bundle\ContactBundle\Form\Handler\GroupHandler
        public: true
        arguments:
            - "@oro_contact.form.group"
            - "@request_stack"
            - "@doctrine.orm.entity_manager"

    oro_contact.form.type.group:
        class: Oro\Bundle\ContactBundle\Form\Type\GroupType
        tags:
            - { name: form.type, alias: oro_contact_group }

    oro_contact.contact.manager.api:
        class: Oro\Bundle\ContactBundle\Entity\Manager\ContactApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\ContactBundle\Entity\Contact'
            - "@doctrine.orm.entity_manager"
            - "@oro_attachment.manager.file.api"

    oro_contact.contact_address.manager.api:
        class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\ContactBundle\Entity\ContactAddress'
            - "@doctrine.orm.entity_manager"

    oro_contact.form.type.contact.api:
        class: Oro\Bundle\ContactBundle\Form\Type\ContactApiType
        arguments:
            - 'Oro\Bundle\ContactBundle\Entity\Contact'
            - 'Oro\Bundle\ContactBundle\Entity\ContactAddress'
        tags:
            - { name: form.type, alias: contact }

    oro_contact.form.contact.api:
        class: Symfony\Component\Form\Form
        public: true
        factory: ['@form.factory', createNamed]
        arguments: ["contact", Oro\Bundle\ContactBundle\Form\Type\ContactApiType, null]

    oro_contact.form.handler.contact.api:
        class: Oro\Bundle\ContactBundle\Form\Handler\ContactHandler
        public: true
        arguments:
            - "@doctrine.orm.entity_manager"

    oro_contact.group.manager.api:
        class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\ContactBundle\Entity\Group'
            - "@doctrine.orm.entity_manager"

    oro_contact.form.type.group.api:
        class: Oro\Bundle\ContactBundle\Form\Type\GroupApiType
        tags:
            - { name: form.type, alias: contact_group }

    oro_contact.form.group.api:
        class: Symfony\Component\Form\Form
        public: true
        factory: ['@form.factory', createNamed]
        arguments: ["contact_group", Oro\Bundle\ContactBundle\Form\Type\GroupApiType, null]

    oro_contact.form.handler.group.api:
        class: Oro\Bundle\ContactBundle\Form\Handler\GroupHandler
        public: true
        arguments:
            - "@oro_contact.form.group.api"
            - "@request_stack"
            - "@doctrine.orm.entity_manager"

    oro_contact.contact_address.form:
        class: Symfony\Component\Form\Form
        public: true
        factory: ['@form.factory', createNamed]
        arguments:
            - "oro_contact_address_form"
            - Oro\Bundle\AddressBundle\Form\Type\TypedAddressType
            - ~
            - { data_class: 'Oro\Bundle\ContactBundle\Entity\ContactAddress' }

    oro_contact.form.handler.contact_address:
        class: Oro\Bundle\AddressBundle\Form\Handler\AddressHandler
        public: true
        arguments:
            - "@doctrine.orm.entity_manager"

    oro_contact.form.autocomplete.contact.search_handler:
        parent: oro_form.autocomplete.full_name.search_handler
        arguments:
            - 'Oro\Bundle\ContactBundle\Entity\Contact'
            - ['namePrefix', 'firstName', 'middleName', 'lastName', 'nameSuffix']
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: contacts, acl_resource: oro_contact_view }

    oro_contact.email.owner.provider:
        class: Oro\Bundle\ContactBundle\Entity\Provider\EmailOwnerProvider
        tags:
            - { name: oro_email.owner.provider, order: 3 }

    oro_contact.subscriber.contact_listener:
        class: Oro\Bundle\ContactBundle\EventListener\ContactListener
        arguments:
            - "@security.token_storage"
        tags:
            - { name: doctrine.orm.entity_listener, entity: Oro\Bundle\ContactBundle\Entity\Contact, event: prePersist }
            - { name: doctrine.orm.entity_listener, entity: Oro\Bundle\ContactBundle\Entity\Contact, event: preUpdate }

    oro_contact.handler.contact_email_address_handler:
        class: Oro\Bundle\ContactBundle\Handler\ContactEmailAddressHandler
        public: false
        arguments:
            - '@oro_entity.orm.insert_from_select_query_executor'
            - '@oro_email.email.address.manager'
            - '@doctrine'

    oro_contact.event_listener.import_listener:
        class: Oro\Bundle\ContactBundle\EventListener\ImportEventListener
        arguments:
            - '@oro_platform.optional_listeners.manager'
            - '@oro_contact.importexport.configuration_provider.contact'
            - '@oro_message_queue.client.message_producer'
        tags:
            - { name: kernel.event_listener, event: akeneo_batch.before_job_execution, method: onBeforeJobExecution }
            - { name: kernel.event_listener, event: akeneo_batch.after_job_execution, method: onAfterJobExecution }

    oro_contact.social_url_formatter:
        class: Oro\Bundle\ContactBundle\Formatter\SocialUrlFormatter
        arguments:
            - '%oro_contact.social_url_format%'

    oro_contact.contact.datagrid_helper:
        class: Oro\Bundle\AddressBundle\Datagrid\CountryDatagridHelper
        public: true

    oro_contact.activity_widget_provider:
        class: Oro\Bundle\UIBundle\Provider\TabMenuWidgetProvider
        arguments:
           - '@oro_entity.entity_identifier_accessor'
           - '@oro_ui.twig.tab_extension'
           - 'contact_activity_tab_panel'
           - 'Oro\Bundle\ContactBundle\Entity\Contact'
        tags:
           - { name: oro_activity.activity_widget_provider, priority: -10 }

    oro_contact.provider.phone.contact:
        class: Oro\Bundle\ContactBundle\Provider\ContactPhoneProvider
        tags:
            - { name: oro_address.phone_provider, class: Oro\Bundle\ContactBundle\Entity\Contact }

    oro_contact.provider.email_recipients:
        class: Oro\Bundle\ContactBundle\Provider\EmailRecipientsProvider
        arguments:
            - "@doctrine"
            - "@oro_email.provider.email_recipients.helper"
        tags:
            - { name: oro_email.recipients_provider, priority: 20 }

    oro_contact.widget_provider.actions.add_contact:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - oro_add_contact_button
            - oro_add_contact_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity }

    oro_contact.handler.contact_email_api:
        class: Oro\Bundle\ContactBundle\Handler\ContactEmailApiHandler
        arguments:
            - "@doctrine.orm.entity_manager"
            - "@security.authorization_checker"
            - '@property_accessor'
        tags:
            - { name: oro_entity.form.entity_field.handler }

    oro_contact.handler.contact_phone_api:
        class: Oro\Bundle\ContactBundle\Handler\ContactPhoneApiHandler
        arguments:
            - "@doctrine.orm.entity_manager"
            - "@security.authorization_checker"
            - '@property_accessor'
        tags:
            - { name: oro_entity.form.entity_field.handler }

    oro_contact.contact_phone.manager.api:
        class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\ContactBundle\Entity\ContactPhone'
            - "@doctrine.orm.entity_manager"

    oro_contact.contact_email.manager.api:
        class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\ContactBundle\Entity\ContactEmail'
            - "@doctrine.orm.entity_manager"

    oro_contact.delete_handler_extension.contact_email:
        class: Oro\Bundle\ContactBundle\Handler\ContactEmailDeleteHandlerExtension
        parent: oro_entity.delete_handler_extension
        arguments:
            - '@security.authorization_checker'
            - '@translator'
        tags:
            - { name: oro_entity.delete_handler_extension, entity: Oro\Bundle\ContactBundle\Entity\ContactEmail }

    oro_contact.delete_handler_extension.contact_phone:
        class: Oro\Bundle\ContactBundle\Handler\ContactPhoneDeleteHandlerExtension
        parent: oro_entity.delete_handler_extension
        arguments:
            - '@security.authorization_checker'
            - '@translator'
        tags:
            - { name: oro_entity.delete_handler_extension, entity: Oro\Bundle\ContactBundle\Entity\ContactPhone }

    oro_contact.formatter.contact_entity_name:
        class: Oro\Bundle\ContactBundle\Formatter\ContactNameFormatter
        arguments:
            - '@oro_locale.formatter.name'

    oro_contact.formatter.contact_entity_name.link:
        tags:
            - { name: oro_service_link, service: oro_contact.formatter.contact_entity_name }

    oro_contact.provider.contact_entity_name:
        class: Oro\Bundle\ContactBundle\Provider\ContactEntityNameProvider
        arguments:
            - '@oro_contact.formatter.contact_entity_name.link'
            - '@oro_locale.dql.formatter.name.link'
        tags:
            - { name: oro_entity.name_provider, priority: 100 }

    oro_contact.event_listener.datagrid.my_contacts_activity:
        class: Oro\Bundle\UserBundle\Datagrid\WidgetOwnerListener
        arguments:
            - '@oro_user.dashboard.owner_helper'
            - '@oro_dashboard.widget_configs'
            - 'owner'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.before.dashboard-my-contacts-activity-grid, method: onResultBefore }

    oro_contact.contacts_view_list:
        class: Oro\Bundle\ContactBundle\Datagrid\ContactsViewList
        public: true
        arguments:
            - '@translator'

    oro_contact.twig.extension:
        class: Oro\Bundle\ContactBundle\Twig\ContactExtension
        public: false
        arguments:
            - '@oro_platform.twig.service_locator'
        tags:
            - { name: twig.extension }
