parameters:
    orocrm_campaign.entity.class:                  OroCRM\Bundle\CampaignBundle\Entity\Campaign
    orocrm_campaign.email_campaign.entity.class:   OroCRM\Bundle\CampaignBundle\Entity\EmailCampaign
    orocrm_campaign.campaign.form.type.class:      OroCRM\Bundle\CampaignBundle\Form\Type\CampaignType
    orocrm_campaign.campaign.manager.api.class:    Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
    orocrm_campaign.email_campaign.manager.api.class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager

    orocrm_campaign.data_transformer.multi_line.class: OroCRM\Bundle\CampaignBundle\Model\Data\Transformer\MultiLineDataTransformer
    orocrm_campaign.form.type.campaign_select.class: OroCRM\Bundle\CampaignBundle\Form\Type\CampaignSelectType
    orocrm_campaign.form.type.email_campaign.class: OroCRM\Bundle\CampaignBundle\Form\Type\EmailCampaignType
    orocrm_campaign.form.type.email_transport_select.class: OroCRM\Bundle\CampaignBundle\Form\Type\EmailTransportSelectType
    orocrm_campaign.transport.email.class: OroCRM\Bundle\CampaignBundle\Transport\EmailTransport
    orocrm_campaign.email_campaign.sender.class: OroCRM\Bundle\CampaignBundle\Model\EmailCampaignSender
    orocrm_campaign.email_transport.provider.class: OroCRM\Bundle\CampaignBundle\Provider\EmailTransportProvider
    orocrm_campaign.email_campaign.sender.builder.class: OroCRM\Bundle\CampaignBundle\Model\EmailCampaignSenderBuilder

    orocrm_campaign.listener.email_campaign_statistic.class: OroCRM\Bundle\CampaignBundle\EventListener\CampaignStatisticDatagridListener
    orocrm_campaign.form.type.internal_transport_settings.class: OroCRM\Bundle\CampaignBundle\Form\Type\InternalTransportSettingsType
    orocrm_campaign.form.subscriber.transport_settings.class: OroCRM\Bundle\CampaignBundle\Form\EventListener\TransportSettingsListener
    orocrm_campaign.form.subscriber.transport_settings_email_template.class: OroCRM\Bundle\CampaignBundle\Form\EventListener\TransportSettingsEmailTemplateListener
    orocrm_campaign.form.handler.email_campaign.class: OroCRM\Bundle\CampaignBundle\Form\Handler\EmailCampaignHandler
services:
    orocrm_campaign.campaign.form.type:
        class: %orocrm_campaign.campaign.form.type.class%
        tags:
            - { name: form.type, alias: orocrm_campaign_form }

    orocrm_campaign.campaign.form:
        class: Symfony\Component\Form\Form
        factory_method: createNamed
        factory_service: form.factory
        arguments:
            - "orocrm_campaign_form"
            - "orocrm_campaign_form"

    orocrm_campaign.email_campaign.form.type:
        class: %orocrm_campaign.form.type.email_campaign.class%
        calls:
            - [addSubscriber, [@orocrm_campaign.form.subscriber.transport_settings]]
        tags:
            - { name: form.type, alias: orocrm_email_campaign }

    orocrm_campaign.email_campaign.form:
        class: Symfony\Component\Form\Form
        factory_method: createNamed
        factory_service: form.factory
        arguments:
            - "orocrm_email_campaign"
            - "orocrm_email_campaign"

    orocrm_campaign.campaign.manager.api:
        class: %orocrm_campaign.campaign.manager.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %orocrm_campaign.entity.class%
            - @doctrine.orm.entity_manager

    orocrm_campaign.email_campaign.manager.api:
        class: %orocrm_campaign.email_campaign.manager.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %orocrm_campaign.email_campaign.entity.class%
            - @doctrine.orm.entity_manager

    orocrm_campaign.data_transformer.multi_line:
        class: %orocrm_campaign.data_transformer.multi_line.class%

    orocrm_campaign.form.autocomplete.campaign.search_handler:
        parent: oro_form.autocomplete.search_handler
        arguments:
            - %orocrm_campaign.entity.class%
            - ["name"]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: campaigns, acl_resource: orocrm_campaign_view }

    orocrm_campaign.form.type.campaign_select:
        class: %orocrm_campaign.form.type.campaign_select.class%
        tags:
            - { name: form.type, alias: "orocrm_campaign_select" }

    orocrm_campaign.form.type.email_transport_select:
        class: %orocrm_campaign.form.type.email_transport_select.class%
        arguments:
            - @orocrm_campaign.email_transport.provider
        tags:
            - { name: form.type, alias: "orocrm_campaign_email_transport_select" }

    orocrm_campaign.transport.email:
        class: %orocrm_campaign.transport.email.class%
        arguments:
            - @oro_email.mailer.processor
            - @oro_email.email_renderer
            - @oro_entity.doctrine_helper
            - @oro_email.email.address.helper
        tags:
            - { name: "orocrm_campaign.email_transport" }

    orocrm_campaign.email_campaign.sender:
        class: %orocrm_campaign.email_campaign.sender.class%
        arguments:
            - @orocrm_marketing_list.provider.marketing_list
            - @oro_config.global
            - @orocrm_marketing_list.model.marketing_list_item_connector
            - @orocrm_marketing_list.provider.contact_information_fields
            - @doctrine
            - @orocrm_campaign.email_transport.provider
        calls:
            - [setLogger, [@logger]]

    orocrm_campaign.email_transport.provider:
        class: %orocrm_campaign.email_transport.provider.class%

    orocrm_campaign.email_campaign.sender.builder:
        class: %orocrm_campaign.email_campaign.sender.builder.class%
        arguments:
            - @orocrm_campaign.email_campaign.sender

    orocrm_campaign.listener.email_campaign_statistic:
        class: %orocrm_campaign.listener.email_campaign_statistic.class%
        arguments:
            - @orocrm_marketing_list.model.helper
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.pre,   method: onPreBuild }
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after, method: onBuildAfter }

    orocrm_campaign.form.type.internal_transport_settings:
        class: %orocrm_campaign.form.type.internal_transport_settings.class%
        arguments:
            - @doctrine
        calls:
            - [addSubscriber, [@orocrm_campaign.form.subscriber.transport_settings_email_template]]
        tags:
            - { name: form.type, alias: "orocrm_campaign_internal_transport_settings" }

    orocrm_campaign.form.subscriber.transport_settings:
        class: %orocrm_campaign.form.subscriber.transport_settings.class%
        arguments:
            - @orocrm_campaign.email_transport.provider
            - @oro_entity.doctrine_helper

    orocrm_campaign.form.subscriber.transport_settings_email_template:
        class: %orocrm_campaign.form.subscriber.transport_settings_email_template.class%
        arguments:
            - @doctrine
            - @security.context

    orocrm_campaign.form.handler.email_campaign:
        class: %orocrm_campaign.form.handler.email_campaign.class%
        scope: request
        arguments:
            - @request
            - @orocrm_campaign.email_campaign.form
            - @doctrine
