parameters:
    oro_email.email.entity.class:                 Oro\Bundle\EmailBundle\Entity\Email
    oro_email.email_folder.entity.class:          Oro\Bundle\EmailBundle\Entity\EmailFolder
    oro_email.email_origin.entity.class:          Oro\Bundle\EmailBundle\Entity\EmailOrigin
    oro_email.email_user.entity.class:            Oro\Bundle\EmailBundle\Entity\EmailUser
    oro_email.email_folder.model.class:           Oro\Bundle\EmailBundle\Model\FolderType
    oro_email.email.cache.manager.class:          Oro\Bundle\EmailBundle\Cache\EmailCacheManager
    oro_email.email_holder_helper.class:          Oro\Bundle\EmailBundle\Tools\EmailHolderHelper
    oro_email.email.address.helper.class:         Oro\Bundle\EmailBundle\Tools\EmailAddressHelper
    oro_email.email.address.manager.class:        Oro\Bundle\EmailBundle\Entity\Manager\EmailAddressManager
    oro_email.email.owner.provider.class:         Oro\Bundle\EmailBundle\Entity\Provider\EmailOwnerProvider
    oro_email.email.owner.provider.storage.class: Oro\Bundle\EmailBundle\Entity\Provider\EmailOwnerProviderStorage
    oro_email.email.owner.manager.class:          Oro\Bundle\EmailBundle\Entity\Manager\EmailOwnerManager
    oro_email.email.model.builder.helper.class:   Oro\Bundle\EmailBundle\Builder\Helper\EmailModelBuilderHelper
    oro_email.email.entity.builder.class:         Oro\Bundle\EmailBundle\Builder\EmailEntityBuilder
    oro_email.email.model.builder.class:          Oro\Bundle\EmailBundle\Builder\EmailModelBuilder
    oro_email.email.entity.batch_processor.class: Oro\Bundle\EmailBundle\Builder\EmailEntityBatchProcessor
    oro_email.email_body_loader_selector.class:   Oro\Bundle\EmailBundle\Provider\EmailBodyLoaderSelector
    oro_email.email_flag_manager_loader_selector.class: Oro\Bundle\EmailBundle\Provider\EmailFlagManagerLoaderSelector
    oro_email.listener.entity_listener.class:     Oro\Bundle\EmailBundle\EventListener\EntityListener
    oro_email.listener.role_subscriber.class:     Oro\Bundle\EmailBundle\EventListener\RoleSubscriber
    oro_email.listener.auto_response_listener.class: Oro\Bundle\EmailBundle\EventListener\AutoResponseListener
    oro_email.manager.autoresponserule.api.class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
    oro_email.autoresponserule_manager.class:     Oro\Bundle\EmailBundle\Manager\AutoResponseManager
    oro_email.manager.email.api.class:            Oro\Bundle\EmailBundle\Entity\Manager\EmailApiEntityManager
    oro_email.manager.email_origin.api.class:     Oro\Bundle\EmailBundle\Entity\Manager\EmailOriginApiEntityManager
    oro_email.manager.email_activity.api.class:   Oro\Bundle\EmailBundle\Entity\Manager\EmailActivityApiEntityManager
    oro_email.manager.email_activity_entity.api.class: Oro\Bundle\EmailBundle\Entity\Manager\EmailActivityEntityApiEntityManager
    oro_email.manager.email_activity_search.api.class: Oro\Bundle\EmailBundle\Entity\Manager\EmailActivitySearchApiEntityManager
    oro_email.manager.email_activity_suggestion.api.class: Oro\Bundle\EmailBundle\Entity\Manager\EmailActivitySuggestionApiEntityManager
    oro_email.entity.cache.warmer.class:          Oro\Bundle\EmailBundle\Cache\EntityCacheWarmer
    oro_email.entity.cache.clearer.class:         Oro\Bundle\EmailBundle\Cache\EntityCacheClearer
    oro_email.direct_mailer.class:                Oro\Bundle\EmailBundle\Mailer\DirectMailer
    oro_email.mailer.processor.class:             Oro\Bundle\EmailBundle\Mailer\Processor
    oro_email.email.activity.manager.class:       Oro\Bundle\EmailBundle\Entity\Manager\EmailActivityManager
    oro_email.email_synchronization_manager.class:  Oro\Bundle\EmailBundle\Sync\EmailSynchronizationManager
    oro_email.known_email_address_checker_factory.class: Oro\Bundle\EmailBundle\Sync\KnownEmailAddressCheckerFactory
    oro_email.twig.extension.email.class:         Oro\Bundle\EmailBundle\Twig\EmailExtension
    oro_email.email.manager.class:                Oro\Bundle\EmailBundle\Entity\Manager\EmailManager
    oro_email.email.flag.manager.class:           Oro\Bundle\EmailBundle\Manager\EmailFlagManager
    oro_email.email.thread.manager.class:         Oro\Bundle\EmailBundle\Entity\Manager\EmailThreadManager
    oro_email.email.thread.provider.class:        Oro\Bundle\EmailBundle\Entity\Provider\EmailThreadProvider
    oro_email.email_attachment_transformer.class: Oro\Bundle\EmailBundle\Tools\EmailAttachmentTransformer
    oro_email.email_websocket.processor.class:    Oro\Bundle\EmailBundle\Model\WebSocket\WebSocketSendProcessor
    oro_email.placeholder.send_email.filter.class: Oro\Bundle\EmailBundle\Placeholder\SendEmailPlaceholderFilter
    oro_email.tools.email_origin_helper.class:    Oro\Bundle\EmailBundle\Tools\EmailOriginHelper

    oro_email.emailtemplate.entity.class:         Oro\Bundle\EmailBundle\Entity\EmailTemplate

    oro_email.autoresponserule.entity.class: Oro\Bundle\EmailBundle\Entity\AutoResponseRule

    # Email template API
    oro_email.manager.emailtemplate.api.class: Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager

    # Entity email user listener
    oro_email.event_listener.email_user_listener.class: Oro\Bundle\EmailBundle\EventListener\EmailUserListener

    # Providers
    oro_email.emailtemplate.variable_provider.class: Oro\Bundle\EmailBundle\Provider\VariablesProvider
    oro_email.emailtemplate.variable_provider.entity.class: Oro\Bundle\EmailBundle\Provider\EntityVariablesProvider
    oro_email.emailtemplate.variable_provider.system.class: Oro\Bundle\EmailBundle\Provider\SystemVariablesProvider
    oro_email.emailtemplate.variable_provider.user.class: Oro\Bundle\EmailBundle\Provider\LoggedUserVariablesProvider
    oro_email.activity_list.provider.class: Oro\Bundle\EmailBundle\Provider\EmailActivityListProvider
    oro_email.related_emails.provider.class: Oro\Bundle\EmailBundle\Provider\RelatedEmailsProvider
    oro_email.email_recipients.provider.class: Oro\Bundle\EmailBundle\Provider\EmailRecipientsProvider
    oro_email.recent_email_recipients.provider.class: Oro\Bundle\EmailBundle\Provider\RecentEmailRecipientsProvider
    oro_email.context_email_recipients.provider.class: Oro\Bundle\EmailBundle\Provider\ContextEmailRecipientsProvider
    oro_email.provider.email_recipients.helper.class: Oro\Bundle\EmailBundle\Provider\EmailRecipientsHelper
    oro_email.provider.emailowners.provider.class: Oro\Bundle\EmailBundle\Provider\EmailOwnersProvider

    # Managers
    oro_email.manager.notification.class: Oro\Bundle\EmailBundle\Manager\EmailNotificationManager

    # Cache keys
    oro_email.cache.available_in_template_key: 'oro_email.available_in_template_fields'

    # Email renderer, twig instance
    oro_email.email_renderer.class: Oro\Bundle\EmailBundle\Provider\EmailRenderer
    oro_email.twig.email_security_policy.class: Twig_Sandbox_SecurityPolicy

    oro_email.helper.datagrid.emails.class:           Oro\Bundle\EmailBundle\Datagrid\EmailGridHelper
    oro_email.datagrid_query_factory.class:           Oro\Bundle\EmailBundle\Datagrid\EmailQueryFactory
    oro_email.emailtemplate.datagrid_view_list.class: Oro\Bundle\EmailBundle\Datagrid\EmailTemplatesViewList
    oro_email.emailtemplate.datagrid_helper.class:    Oro\Bundle\EmailBundle\Datagrid\EmailTemplateGridHelper
    oro_email.emailfolder.datagrid_view_list.class:   Oro\Bundle\EmailBundle\Datagrid\EmailFolderViewList
    oro_email.emailseen.datagrid_view_list.class:   Oro\Bundle\EmailBundle\Datagrid\EmailSeenViewList

    # Datagrid event listeners
    oro_email.listener.datagrid.email.class:        Oro\Bundle\EmailBundle\EventListener\Datagrid\EmailGridListener
    oro_email.listener.datagrid.activity.class:     Oro\Bundle\EmailBundle\EventListener\Datagrid\ActivityGridListener
    oro_email.listener.datagrid.user_emails.recent.class: Oro\Bundle\EmailBundle\EventListener\Datagrid\RecentEmailGridListener

    # Email Action for workflows
    oro_email.workflow.action.send_email.class: Oro\Bundle\EmailBundle\Workflow\Action\SendEmail
    oro_email.workflow.action.send_email_template.class: Oro\Bundle\EmailBundle\Workflow\Action\SendEmailTemplate

    oro_email.listener.search_listener.class: Oro\Bundle\EmailBundle\EventListener\SearchListener
    oro_email.listener.email_body_add_listener.class: Oro\Bundle\EmailBundle\EventListener\EmailBodyAddListener
    oro_email.listener.replace_embedded_attachments_listener.class: Oro\Bundle\EmailBundle\EventListener\ReplaceEmbeddedAttachmentsListener

    # Validators
    oro_email.validator.email_template_syntax_validator.class: Oro\Bundle\EmailBundle\Validator\EmailTemplateSyntaxValidator
    oro_email.validator.email_address_validator.class: Oro\Bundle\EmailBundle\Validator\EmailAddressValidator
    oro_email.validator.email_recipients_validator.class: Oro\Bundle\EmailBundle\Validator\EmailRecipientsValidator

    oro_email.manager.email_attachment_manager.class: Oro\Bundle\EmailBundle\Manager\EmailAttachmentManager
    oro_email.provider.email_attachment_provider.class: Oro\Bundle\EmailBundle\Provider\EmailAttachmentProvider
    oro_email.acl.voter.email_voter.class: Oro\Bundle\EmailBundle\Acl\Voter\EmailVoter

    # Email DataGrid
    oro_email.datagrid.origin_folder.provider.class: Oro\Bundle\EmailBundle\Datagrid\OriginFolderFilterProvider

    # Mailboxes
    oro_email.mailbox.entity.class:                     Oro\Bundle\EmailBundle\Entity\Mailbox
    oro_email.mailbox.process_storage.class:            Oro\Bundle\EmailBundle\Mailbox\MailboxProcessStorage
    oro_email.mailbox_email_owner_provider.class:       Oro\Bundle\EmailBundle\Provider\MailboxEmailOwnerProvider
    oro_email.mailbox_choice_list.class:                Oro\Bundle\EmailBundle\Datagrid\MailboxChoiceList
    oro_email.mailbox.manager.api.class:                Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
    oro_email.mailbox.entity_name_provider.class:       Oro\Bundle\EmailBundle\Provider\MailboxEntityNameProvider
    oro_email.listener.mailbox_process_trigger_listener.class: Oro\Bundle\EmailBundle\EventListener\MailboxProcessTriggerListener
    oro_email.listener.mailbox.authorization.class:     Oro\Bundle\EmailBundle\EventListener\MailboxAuthorizationListener
    oro_email.listener.datagrid.mailbox_grid.class:     Oro\Bundle\EmailBundle\EventListener\Datagrid\MailboxGridListener
    oro_email.autocomplete.mailbox_user_search_handler.class: Oro\Bundle\EmailBundle\Autocomplete\MailboxUserSearchHandler
    oro_email.mailbox.manager.class:                    Oro\Bundle\EmailBundle\Entity\Manager\MailboxManager

    # Workflow conditions
    oro_email.workflow.condition.instanceof.class:      Oro\Bundle\EmailBundle\Model\Condition\IsInstanceOf
    oro_email.workflow.condition.has_count.class:       Oro\Bundle\EmailBundle\Model\Condition\HasCount

    # Workflow actions
    oro_email.workflow.action.parse_first_name.class:   Oro\Bundle\EmailBundle\Model\Action\ParseFirstNameFromEmailAddress
    oro_email.workflow.action.parse_last_name.class:    Oro\Bundle\EmailBundle\Model\Action\ParseLastNameFromEmailAddress
    oro_email.workflow.action.request_mailboxes.class:  Oro\Bundle\EmailBundle\Model\Action\RequestMailboxes
    oro_email.workflow.action.strip_html_tags.class:    Oro\Bundle\EmailBundle\Model\Action\StripHtmlTags
    oro_email.workflow.action.add_activity_target.class: Oro\Bundle\EmailBundle\Model\Action\AddActivityTarget

    oro_email.listener.search_aliases_listener.class: Oro\Bundle\EmailBundle\EventListener\SearchAliasesListener
    oro_email.listener.prepare_result_item_listener.class: Oro\Bundle\EmailBundle\EventListener\PrepareResultItemListener
    oro_email.listener.prepare_context_title_listener.class: Oro\Bundle\EmailBundle\EventListener\PrepareContextTitleListener
    oro_email.listener.activity_list_pre_query_build_listener.class: Oro\Bundle\EmailBundle\EventListener\ActivityListPreQueryBuildListener
    oro_email.model.email_activity_updates.class: Oro\Bundle\EmailBundle\Model\EmailActivityUpdates

services:
    oro_email.entity.cache.warmer:
        class: %oro_email.entity.cache.warmer.class%
        arguments:
            - '@oro_email.email.owner.provider.storage'
            - %oro_email.entity.cache_dir%
            - %oro_email.entity.cache_namespace%
            - %oro_email.entity.proxy_name_template%
            - '@kernel'
        tags:
            - { name: kernel.cache_warmer, priority: 30 }
            - { name: oro_entity_extend.warmer }

    oro_email.entity.cache.clearer:
        class: %oro_email.entity.cache.clearer.class%
        deprecated: ~
        arguments:
            - %oro_email.entity.cache_dir%
            - %oro_email.entity.proxy_name_template%

    oro_email.email.cache.manager:
        class: %oro_email.email.cache.manager.class%
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@event_dispatcher'
            - '@oro_email.email_body_synchronizer'

    oro_email.email_holder_helper:
        class: %oro_email.email_holder_helper.class%
        arguments:
            - '@oro_entity_config.provider.extend'

    oro_email.email.address.helper:
        class: %oro_email.email.address.helper.class%

    oro_email.email_body_loader_selector:
        public: false
        class: %oro_email.email_body_loader_selector.class%

    oro_email.email_flag_manager_loader_selector:
        public: false
        class: %oro_email.email_flag_manager_loader_selector.class%

    oro_email.email_address.entity_manager:
        parent: oro_entity.abstract_entity_manager
        arguments:
            - 'OroEmailBundle:EmailAddress'

    oro_email.link.email_address.entity_manager:
        tags:
            - { name: oro_service_link,  service: oro_email.email_address.entity_manager }

    oro_email.email.address.manager:
        class: %oro_email.email.address.manager.class%
        arguments:
            - %oro_email.entity.cache_namespace%
            - %oro_email.entity.proxy_name_template%
        calls:
            - [setEntityManagerLink, ['@oro_email.link.email_address.entity_manager']]

    oro_email.email.owner.provider.storage:
        public: false
        class: %oro_email.email.owner.provider.storage.class%

    oro_email.email.owner.provider:
        public: false
        class: %oro_email.email.owner.provider.class%
        arguments:
            - '@oro_email.email.owner.provider.storage'

    oro_email.email.owner.manager:
        public: false
        class: %oro_email.email.owner.manager.class%
        arguments:
            - '@oro_email.email.owner.provider.storage'
            - '@oro_email.email.address.manager'

    oro_email.email.model.builder.helper:
        class: %oro_email.email.model.builder.helper.class%
        arguments:
            - '@oro_entity.routing_helper'
            - '@oro_email.email.address.helper'
            - '@oro_entity.entity_name_resolver'
            - '@oro_security.security_facade'
            - '@oro_email.email.address.manager'
            - '@doctrine.orm.entity_manager'
            - '@oro_email.email.cache.manager'
            - '@templating'
            - '@oro_email.mailbox.manager'

    oro_email.email.entity.builder:
        class: %oro_email.email.entity.builder.class%
        scope: prototype
        arguments:
            - '@oro_email.email.entity.batch_processor'
            - '@oro_email.email.address.manager'
            - '@oro_email.email.address.helper'

    oro_email.email.model.builder:
        class: %oro_email.email.model.builder.class%
        arguments:
            - '@oro_email.email.model.builder.helper'
            - '@doctrine.orm.entity_manager'
            - '@oro_config.user'
            - '@oro_email.activity_list.provider'
            - '@oro_email.provider.email_attachment_provider'
            - '@oro_email.form.factory'
        calls:
            - [setRequest, ["@?request="]]

    oro_email.email_websocket.processor:
        class: %oro_email.email_websocket.processor.class%
        arguments:
            - '@oro_wamp.publisher'

    oro_email.event_listener.email_user_listener:
        class: %oro_email.event_listener.email_user_listener.class%
        arguments:
            - '@oro_email.email_websocket.processor'
        tags:
            - { name: doctrine.event_listener, event: onFlush, priority: 1 }
            - { name: doctrine.event_listener, event: postFlush, priority: 1 }

    oro_email.email.entity.batch_processor:
        class: %oro_email.email.entity.batch_processor.class%
        public: false
        scope: prototype
        arguments:
            - '@oro_email.email.address.manager'
            - '@oro_email.email.owner.provider'
            - '@event_dispatcher'

    oro_email.link.email.activity.manager:
        tags:
            - { name: oro_service_link,  service: oro_email.email.activity.manager }

    oro_email.link.email.thread.manager:
        tags:
            - { name: oro_service_link,  service: oro_email.email.thread.manager }

    oro_email.listener.entity_listener:
        class: %oro_email.listener.entity_listener.class%
        arguments:
            - '@oro_email.email.owner.manager'
            - '@oro_email.link.email.activity.manager'
            - '@oro_email.link.email.thread.manager'
            - '@oro_email.model.email_activity_updates'
        tags:
            - { name: doctrine.event_listener, event: onFlush }
            - { name: doctrine.event_listener, event: postFlush }
            - { name: doctrine.event_listener, event: postRemove }

    oro_email.acl.manager.link:
        tags:
            - { name: oro_service_link,  service: oro_security.acl.manager }

    oro_email.listener.role_subscriber:
        class: %oro_email.listener.role_subscriber.class%
        arguments:
            - '@oro_email.acl.manager.link'
        tags:
            - { name: doctrine.event_subscriber }

    oro_email.listener.auto_response_listener:
        class: %oro_email.listener.auto_response_listener.class%
        arguments:
            - '@oro_email.link.autoresponserule_manager'
        tags:
            - { name: doctrine.event_listener, event: onFlush }
            - { name: doctrine.event_listener, event: postFlush }

    oro_email.manager.autoresponserule.api:
        class: %oro_email.manager.autoresponserule.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_email.autoresponserule.entity.class%
            - '@doctrine.orm.entity_manager'

    oro_email.autoresponserule_manager:
        class: %oro_email.autoresponserule_manager.class%
        arguments:
            - '@doctrine'
            - '@oro_email.email.model.builder'
            - '@oro_email.mailer.processor'
            - '@oro_email.email_renderer'
            - '@logger'
            - %locale%

    oro_email.link.autoresponserule_manager:
        tags:
            - { name: oro_service_link,  service: oro_email.autoresponserule_manager }

    oro_email.manager.email.api:
        class: %oro_email.manager.email.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_email.email.entity.class%
            - '@doctrine.orm.entity_manager'

    oro_email.manager.email_origin.api:
        class: %oro_email.manager.email_origin.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_email.email_origin.entity.class%
            - '@doctrine.orm.entity_manager'

    oro_email.direct_mailer:
        class: %oro_email.direct_mailer.class%
        arguments:
            - '@mailer'
            - '@service_container'

    # Email template API
    oro_email.manager.emailtemplate.api:
        class: %oro_email.manager.emailtemplate.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_email.emailtemplate.entity.class%
            - '@doctrine.orm.entity_manager'

    oro_email.cache:
          parent: oro.cache.abstract
          calls:
              - [setNamespace, [ 'oro_email' ] ]

    # Available variables services
    oro_email.listener.config_listener:
        class: Oro\Bundle\EmailBundle\EventListener\EntityConfigListener
        arguments:
            - '@oro_email.cache'
            - %oro_email.cache.available_in_template_key%
        tags:
            - { name: kernel.event_listener, event: oro.entity_config.pre_flush, method: preFlush }

    # email template twig instance
    oro_email.twig.string_loader:
        class: Twig_Loader_String

    oro_email.email_renderer:
        class: %oro_email.email_renderer.class%
        arguments:
            - '@oro_email.twig.string_loader'
            -  # twig environment options
              strict_variables: true
            - '@oro_email.emailtemplate.variable_provider'
            - '@oro_email.cache'
            - %oro_email.cache.available_in_template_key%
            - '@oro_email.twig.email_sandbox'
            - '@translator'
        lazy: true

    oro_email.twig.email_security_policy:
        class: %oro_email.twig.email_security_policy.class%
        arguments:
            # tags
            - [ 'app', 'for', 'if', 'spaceless' ]
            # filters
            - [ 'default', 'date', 'escape', 'format', 'length', 'lower', 'nl2br', 'number_format', 'title', 'trim', 'upper', 'oro_html_sanitize' ]
            # methods
            - []
            # properties
            - []
            # functions
            - [ 'date' ]

    oro_email.twig.email_sandbox:
        class: Twig_Extension_Sandbox
        arguments:
            - '@oro_email.twig.email_security_policy'
            - true # use sandbox globally in instance

    oro_email.emailtemplate.variable_provider:
        class: %oro_email.emailtemplate.variable_provider.class%

    oro_email.emailtemplate.variable_provider.entity:
        class: %oro_email.emailtemplate.variable_provider.entity.class%
        arguments:
            - '@translator'
            - '@oro_entity_config.config_manager'
            - '@doctrine'
            - '@oro_ui.formatter'
        lazy: true
        public: false
        tags:
            - { name: oro_email.emailtemplate.variable_provider, scope: entity }

    oro_email.emailtemplate.variable_provider.system:
        class: %oro_email.emailtemplate.variable_provider.system.class%
        lazy: true
        arguments:
            - '@translator'
            - '@oro_config.user'
            - '@oro_locale.formatter.date_time'
        lazy: true
        public: false
        tags:
            - { name: oro_email.emailtemplate.variable_provider, scope: system }

    oro_email.emailtemplate.variable_provider.user:
        class: %oro_email.emailtemplate.variable_provider.user.class%
        lazy: true
        arguments:
            - '@translator'
            - '@oro_security.security_facade'
            - '@oro_entity.entity_name_resolver'
            - '@oro_config.user'
        lazy: true
        public: false
        tags:
            - { name: oro_email.emailtemplate.variable_provider, scope: system }

    oro_email.validator.email_template_syntax:
        class: %oro_email.validator.email_template_syntax_validator.class%
        arguments:
            - '@oro_email.email_renderer'
            - '@oro_locale.settings'
            - '@oro_entity_config.provider.entity'
            - '@translator'
        tags:
            - { name: validator.constraint_validator, alias: oro_email.email_template_syntax_validator }

    oro_email.validator.email_address_validator:
        class: %oro_email.validator.email_address_validator.class%
        arguments:
            - '@oro_email.email.address.helper'
        tags:
            - { name: validator.constraint_validator, alias: oro_email.email_address_validator }

    oro_email.validator.email_recipients:
        class: %oro_email.validator.email_recipients_validator.class%
        tags:
            - { name: validator.constraint_validator, alias: oro_email.email_recipients_validator }

    oro_email.datagrid_query_factory:
        class: %oro_email.datagrid_query_factory.class%
        arguments:
            - '@oro_email.email.owner.provider.storage'
            - '@oro_entity.entity_name_resolver'
            - '@oro_email.mailbox.manager'
            - '@oro_security.security_facade'

    oro_email.emailtemplate.datagrid_view_list:
        class: %oro_email.emailtemplate.datagrid_view_list.class%
        arguments:
            - '@translator'

    oro_email.emailfolder.datagrid_view_list:
        class: %oro_email.emailfolder.datagrid_view_list.class%
        arguments:
            - '@translator'
            - '@oro_email.mailbox_choice_list'

    oro_email.emailseen.datagrid_view_list:
        class: %oro_email.emailseen.datagrid_view_list.class%
        arguments:
            - '@translator'
            - '@oro_email.mailbox_choice_list'

    oro_email.emailtemplate.datagrid_helper:
        class: %oro_email.emailtemplate.datagrid_helper.class%
        arguments:
            - '@oro_entity.entity_provider'
            - '@translator'

    oro_email.mailer.processor:
        class: %oro_email.mailer.processor.class%
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_email.direct_mailer'
            - '@oro_email.email.address.helper'
            - '@oro_email.email.entity.builder='
            - '@oro_email.email.activity.manager'
            - '@event_dispatcher'
            - '@oro_security.encoder.mcrypt'
            - '@oro_email.tools.email_origin_helper'

    oro_email.workflow.action.send_email:
        class: %oro_email.workflow.action.send_email.class%
        arguments:
            - '@oro_action.context_accessor'
            - '@oro_email.mailer.processor'
            - '@oro_email.email.address.helper'
            - '@oro_entity.entity_name_resolver'
        calls:
            - [setLogger, ['@logger']]
        tags:
            - { name: oro_workflow.action, alias: send_email }

    oro_email.workflow.action.send_email_template:
        class: %oro_email.workflow.action.send_email_template.class%
        arguments:
            - '@oro_action.context_accessor'
            - '@oro_email.mailer.processor'
            - '@oro_email.email.address.helper'
            - '@oro_entity.entity_name_resolver'
            - '@oro_email.email_renderer'
            - '@doctrine.orm.entity_manager'
            - '@validator'
        calls:
            - [setLogger, ['@logger']]
        tags:
            - { name: oro_workflow.action, alias: send_email_template }
            - { name: oro_action.action, alias: send_email_template }

    oro_email.helper.datagrid.emails:
        class: %oro_email.helper.datagrid.emails.class%
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_email.email_synchronization_manager'
            - '@oro_activity.manager'
            - %oro_user.entity.class%

    oro_email.listener.datagrid.email:
        class: %oro_email.listener.datagrid.email.class%
        arguments:
            - '@oro_email.datagrid_query_factory'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.base-email-grid, method: onBuildAfter }
            - { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.before_query.base-email-grid, method: onResultBeforeQuery, priority: -255 }

    oro_email.listener.datagrid.activity:
        class: %oro_email.listener.datagrid.activity.class%
        arguments:
            - '@oro_email.helper.datagrid.emails'
            - '@oro_entity.routing_helper'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.activity-email-grid, method: onBuildAfter }

    oro_email.listener.datagrid.recent_emails.inbox:
        class: %oro_email.listener.datagrid.user_emails.recent.class%
        arguments:
            - '@oro_email.helper.datagrid.emails'
            - '@oro_email.datagrid_query_factory'
        tags:
          - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.dashboard-recent-emails-inbox-grid, method: onBuildAfter }

    oro_email.listener.datagrid.recent_emails.sent:
        class: %oro_email.listener.datagrid.user_emails.recent.class%
        arguments:
            - '@oro_email.helper.datagrid.emails'
            - '@oro_email.datagrid_query_factory'
        tags:
          - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.dashboard-recent-emails-sent-grid, method: onBuildAfter }

    oro_email.listener.datagrid.recent_emails.new:
        class: %oro_email.listener.datagrid.user_emails.recent.class%
        arguments:
            - '@oro_email.helper.datagrid.emails'
            - '@oro_email.datagrid_query_factory'
        tags:
          - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.dashboard-recent-emails-new-grid, method: onBuildAfter }

    oro_email.email_synchronization_manager:
        class: %oro_email.email_synchronization_manager.class%
        arguments:
            - '@service_container'

    oro_email.known_email_address_checker_factory:
        class: %oro_email.known_email_address_checker_factory.class%
        public: false
        scope: prototype
        arguments:
            - '@doctrine'
            - '@oro_email.email.address.manager'
            - '@oro_email.email.address.helper'
            - '@oro_email.email.owner.provider.storage'
            - %oro_email.email_sync_exclusions%

    oro_email.email.activity.manager:
        class: %oro_email.email.activity.manager.class%
        arguments:
            - '@oro_activity.manager'
            - '@oro_email.activity_list.provider'
            - '@oro_email.email.thread.provider'
            - '@security.token_storage'
            - '@oro_security.owner.entity_owner_accessor.link'
            - "@=service('doctrine').getManagerForClass('OroEmailBundle:Email')"

    oro_email.email.thread.provider:
        class: %oro_email.email.thread.provider.class%

    oro_email.email.thread.manager:
        class: %oro_email.email.thread.manager.class%
        arguments:
            - '@oro_email.email.thread.provider'
            - "@=service('doctrine').getManagerForClass('OroEmailBundle:EmailThread')"

    oro_email.email.manager:
        class: %oro_email.email.manager.class%
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_email.email.thread.manager'
            - '@oro_email.email.thread.provider'
            - '@oro_security.security_facade'
            - '@oro_email.mailbox.manager'

    oro_email.twig.extension.email:
        class: %oro_email.twig.extension.email.class%
        arguments:
            - '@oro_email.email_holder_helper'
            - '@oro_email.email.address.helper'
            - '@oro_email.manager.email_attachment_manager'
            - '@doctrine.orm.entity_manager'
            - '@oro_email.mailbox.process_storage'
            - '@oro_security.security_facade'
            - '@oro_email.related_emails.provider'
            - '@oro_email.tools.email_body_helper'
        tags:
            - { name: twig.extension }

    oro_email.listener.search_listener:
          class: %oro_email.listener.search_listener.class%
          tags:
              - { name: kernel.event_listener, event: oro_search.prepare_entity_map, method: prepareEntityMapEvent, priority: 10 }

    oro_email.link.entity_manager:
        tags:
            - { name: oro_service_link, service: doctrine.orm.entity_manager }

    oro_email.mailbox.process_storage.link:
        tags:
            - { name: oro_service_link, service: oro_email.mailbox.process_storage }

    oro_email.activity_list.provider:
        class: %oro_email.activity_list.provider.class%
        arguments:
           - '@oro_entity.doctrine_helper'
           - '@oro_email.link.entity_manager'
           - '@oro_entity.entity_name_resolver'
           - '@router'
           - '@oro_entity_config.config_manager'
           - '@oro_email.email.thread.provider'
           - '@oro_ui.html_tag_helper'
           - '@oro_security.security_facade.link'
           - '@oro_email.mailbox.process_storage.link'
           - '@oro_activity.association_helper'
           - '@oro_comment.association_helper'
           - '@oro_email.tools.email_body_helper'
        calls:
           - [ setSecurityContextLink, ['@security.context.link'] ]
        tags:
           - {name: oro_activity_list.provider, priority: 30}

    oro_email.related_emails.provider:
        class: %oro_email.related_emails.provider.class%
        arguments:
            - '@doctrine'
            - '@oro_entity_config.config_manager'
            - '@oro_security.security_facade'
            - '@oro_locale.formatter.name'
            - '@oro_email.email.address.helper'
            - '@oro_email.provider.email_recipients.helper'

    oro_email.email_recipients.provider:
        class: %oro_email.email_recipients.provider.class%
        arguments:
            - '@translator'
            - '@oro_email.provider.email_recipients.helper'

    oro_email.recent_email_recipients.provider:
        class: %oro_email.recent_email_recipients.provider.class%
        arguments:
            - '@oro_security.security_facade'
            - '@oro_email.related_emails.provider'
            - '@oro_security.acl_helper'
            - '@doctrine'
            - '@oro_email.email.owner.provider'
            - '@oro_email.provider.email_recipients.helper'
        tags:
            - { name: oro_email.recipients_provider }

    oro_email.context_email_recipients.provider:
        class: %oro_email.context_email_recipients.provider.class%
        arguments:
            - '@oro_email.related_emails.provider'
        tags:
            - { name: oro_email.recipients_provider, priority: 10 }

    oro_email.provider.emailowners.provider:
        class: %oro_email.provider.emailowners.provider.class%
        arguments:
            - '@oro_activity_list.provider.chain'
            - '@oro_email.email.owner.provider.storage'
            - '@doctrine'

    oro_email.provider.email_recipients.helper:
        class: %oro_email.provider.email_recipients.helper.class%
        arguments:
            - '@oro_security.acl_helper'
            - '@oro_locale.dql.formatter.name'
            - '@oro_locale.formatter.name'
            - '@oro_entity_config.config_manager'
            - '@translator'
            - '@oro_email.email.owner.provider'
            - '@doctrine'
            - '@oro_email.email.address.helper'
            - '@oro_search.index'

    oro_email.link.formatter.name:
        tags:
            - { name: oro_service_link,  service: oro_locale.formatter.name }

    oro_email.manager.email_attachment_manager:
        class: %oro_email.manager.email_attachment_manager.class%
        arguments:
            - '@oro_attachment.file_manager'
            - '@doctrine.orm.entity_manager'
            - '@router'
            - '@oro_attachment.validator.file_config_validator'
            - '@oro_attachment.association_helper'

    oro_email.listener.email_body_add_listener:
        class: %oro_email.listener.email_body_add_listener.class%
        arguments:
            - '@oro_email.manager.email_attachment_manager'
            - '@oro_entity_config.provider.attachment'
            - '@oro_email.activity_list.provider'
            - '@oro_security.security_facade.link'
            - '@oro_activity_list.provider.chain'
            - '@doctrine.orm.entity_manager'
        tags:
            - { name: kernel.event_listener, event: oro_email.email_body_added, method: linkToScope, priority: 10 }
            - { name: kernel.event_listener, event: oro_email.email_body_added, method: updateActivityDescription, priority: 20 }

    oro_email.listener.replace_embedded_attachments_listener:
        class: %oro_email.listener.replace_embedded_attachments_listener.class%
        tags:
            - { name: kernel.event_listener, event: oro_email.email_body_loaded, method: replace }

    oro_email.provider.email_attachment_provider:
        class: %oro_email.provider.email_attachment_provider.class%
        arguments:
            - '@oro_email.email.thread.provider'
            - '@doctrine.orm.entity_manager'
            - '@oro_attachment.provider.attachment'
            - '@oro_email.email_attachment_transformer'

    oro_email.email_attachment_transformer:
        class: %oro_email.email_attachment_transformer.class%
        arguments:
            - '@oro_email.form.factory'
            - '@oro_attachment.file_manager'
            - '@oro_attachment.manager'
            - '@oro_email.manager.email_attachment_manager'

    oro_email.email_importance_transformer:
        class: Oro\Bundle\EmailBundle\Form\DataTransformer\EmailImportanceApiTransformer

    oro_email.email_body_type_transformer:
        class: Oro\Bundle\EmailBundle\Form\DataTransformer\EmailBodyTypeApiTransformer

    oro_email.acl.voter.email_voter:
        class: %oro_email.acl.voter.email_voter.class%
        arguments:
            - '@service_container'
        tags:
            - { name: security.voter }

    oro_email.entity_alias_provider:
        class: Oro\Bundle\EmailBundle\Provider\EmailEntityAliasProvider
        public: false
        arguments:
            - '@oro_email.email.address.manager'
        tags:
            - { name: oro_entity.alias_provider }

    oro_email.manager.email_activity.api:
        class: %oro_email.manager.email_activity.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_email.email.entity.class%
            - '@doctrine.orm.entity_manager'
            - '@oro_activity.manager'
            - '@security.token_storage'

    oro_email.manager.email_activity_entity.api:
        class: %oro_email.manager.email_activity_entity.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_email.email.entity.class%
            - '@doctrine.orm.entity_manager'
            - '@oro_activity.manager'
            - '@security.token_storage'

    oro_email.manager.email_activity_search.api:
        class: %oro_email.manager.email_activity_search.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_email.email.entity.class%
            - '@doctrine.orm.entity_manager'
            - '@oro_activity.manager'
            - '@oro_search.index'
            - '@oro_entity.entity_name_resolver'

    oro_email.manager.email_activity_suggestion.api:
        class: %oro_email.manager.email_activity_suggestion.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_email.email.entity.class%
            - '@doctrine.orm.entity_manager'
            - '@oro_activity.manager'
            - '@oro_search.index'
            - '@oro_entity.entity_name_resolver'
        calls:
            - [setTokenStorage, ['@security.token_storage']]

    oro_email.email.flag.manager:
        class: %oro_email.email.flag.manager.class%
        arguments:
            - '@oro_email.email_flag_manager_loader_selector'
            - '@doctrine.orm.entity_manager'
        calls:
            - [setLogger, ['@logger']]

    oro_email.manager.notification:
        class: %oro_email.manager.notification.class%
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_ui.html_tag_helper'
            - '@router'
            - '@oro_entity_config.config_manager'
            - '@oro_email.tools.email_body_helper'

    oro_email.datagrid.origin_folder.provider:
        class: %oro_email.datagrid.origin_folder.provider.class%
        arguments:
            - '@doctrine'
            - '@oro_security.security_facade'

    oro_email.mailbox.process_storage:
        class: %oro_email.mailbox.process_storage.class%

    oro_email.mailbox_email_owner_provider:
        class: %oro_email.mailbox_email_owner_provider.class%
        tags:
            - { name: oro_email.owner.provider, order: 2 }

    oro_email.mailbox_choice_list:
        class: %oro_email.mailbox_choice_list.class%
        arguments:
            - '@doctrine'
            - '@oro_security.security_facade'
            - '@oro_email.mailbox.manager'

    oro_email.mailbox.manager.api:
        class: %oro_email.mailbox.manager.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_email.mailbox.entity.class%
            - '@doctrine.orm.entity_manager'

    oro_email.mailbox.entity_name_provider:
        class: %oro_email.mailbox.entity_name_provider.class%
        arguments:
            - '@translator.default'
        tags:
            - { name: oro_entity.name_provider, priority: 0}

    oro_email.link.mailbox_process_storage:
        tags:
            - { name: oro_service_link,  service: oro_email.mailbox.process_storage }

    oro_email.listener.mailbox_process_trigger_listener:
        class: %oro_email.listener.mailbox_process_trigger_listener.class%
        arguments:
            - '@oro_workflow.process.process_handler'
            - '@oro_email.link.mailbox_process_storage'
            - '@doctrine'
        tags:
            - { name: doctrine.event_listener, event: onFlush }
            - { name: doctrine.event_listener, event: postFlush }
        calls:
            - [setLogger, ['@logger']]

    oro_email.autocomplete.mailbox_user_search_handler:
        class: %oro_email.autocomplete.mailbox_user_search_handler.class%
        parent: oro_user.autocomplete.user.search_handler
        calls:
           - [setSecurityFacade, ['@oro_security.security_facade']]

    oro_email.listener.mailbox.authorization:
        class: %oro_email.listener.mailbox.authorization.class%
        arguments:
            - '@doctrine'
            - '@oro_security.security_facade'
        tags:
            - { name: kernel.event_listener, event: kernel.controller, method: onKernelController }

    oro_email.listener.datagrid.mailbox_grid:
        class: %oro_email.listener.datagrid.mailbox_grid.class%
        arguments:
            - '@doctrine'
            - '@oro_security.acl_helper'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.pre.base-mailboxes-grid, method: onPreBuild }
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.base-mailboxes-grid, method: onBuildAfter }

    oro_email.mailbox.manager:
        class: %oro_email.mailbox.manager.class%
        arguments:
            - '@doctrine'

    oro_email.workflow.condition.instanceof:
        class: %oro_email.workflow.condition.instanceof.class%
        tags:
            - { name: oro_workflow.condition, alias: instanceof }

    oro_email.workflow.condition.has_count:
        class: %oro_email.workflow.condition.has_count.class%
        tags:
            - { name: oro_workflow.condition, alias: has_count }

    oro_email.workflow.action.parse_first_name:
        class: %oro_email.workflow.action.parse_first_name.class%
        arguments:
            - '@oro_action.context_accessor'
            - '@oro_email.email.address.helper'
        tags:
            - { name: oro_workflow.action, alias: parse_first_name_from_email_address }

    oro_email.workflow.action.parse_last_name:
        class: %oro_email.workflow.action.parse_last_name.class%
        arguments:
            - '@oro_action.context_accessor'
            - '@oro_email.email.address.helper'
        tags:
            - { name: oro_workflow.action, alias: parse_last_name_from_email_address }

    oro_email.workflow.action.request_mailboxes:
        class: %oro_email.workflow.action.request_mailboxes.class%
        arguments:
            - '@oro_action.context_accessor'
            - '@doctrine'
            - '@oro_email.mailbox.process_storage'
        tags:
            - { name: oro_workflow.action, alias: request_mailboxes|find_mailboxes }

    oro_email.workflow.action.strip_html_tags:
        class: %oro_email.workflow.action.strip_html_tags.class%
        arguments:
            - '@oro_action.context_accessor'
            - '@oro_ui.html_tag_helper'
        tags:
            - { name: oro_workflow.action, alias: strip_html_tags }

    oro_email.workflow.action.add_activity_target:
        class: %oro_email.workflow.action.add_activity_target.class%
        arguments:
            - '@oro_action.context_accessor'
            - '@oro_email.email.activity.manager'
            - '@oro_activity_list.provider.chain'
            - '@doctrine.orm.entity_manager'
        tags:
            - { name: oro_workflow.action, alias: add_email_activity_target }

    oro_email.placeholder.send_email.filter:
        class: %oro_email.placeholder.send_email.filter.class%
        arguments:
            - '@oro_activity.manager'

    oro_email.tools.email_origin_helper:
        class: %oro_email.tools.email_origin_helper.class%
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_security.security_facade.link'
            - '@oro_email.email.owner.provider'
            - '@oro_email.email.address.helper'

    oro_email.listener.search_aliases_listener:
        class: %oro_email.listener.search_aliases_listener.class%
        tags:
            - { name: kernel.event_listener, event: oro_activity.search_aliases, method: addEmailAliasEvent }

    oro_email.listener.prepare_result_item_listener:
        class: %oro_email.listener.prepare_result_item_listener.class%
        arguments:
            - '@router'
        tags:
            - { name: kernel.event_listener, event: oro_search.prepare_result_item, method: prepareEmailItemDataEvent }

    oro_email.listener.prepare_context_title_listener:
        class: %oro_email.listener.prepare_context_title_listener.class%
        arguments:
            - '@router'
            - '@oro_entity.doctrine_helper'
        tags:
            - { name: kernel.event_listener, event: oro_activity.context_title, method: prepareEmailContextTitleEvent }

    oro_email.listener.activity_list_pre_query_build_listener:
        class: %oro_email.listener.activity_list_pre_query_build_listener.class%
        arguments:
            - '@oro_entity.doctrine_helper'
        tags:
            - { name: kernel.event_listener, event: oro_activity_list.activity_list_pre_query_build, method: prepareIdsForEmailThreadEvent }

    oro_email.email_body_synchronizer:
        class: Oro\Bundle\EmailBundle\Sync\EmailBodySynchronizer
        arguments:
            - '@oro_email.email_body_loader_selector'
            - '@doctrine'
            - '@event_dispatcher'
        calls:
            - [setLogger, ['@logger']]

    oro_email.model.email_activity_updates:
        class: %oro_email.model.email_activity_updates.class%
        arguments:
            - '@oro_email.provider.emailowners.provider'

    oro_email.command.association_manager:
        class: Oro\Bundle\EmailBundle\Command\Manager\AssociationManager
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@oro_email.email.activity.manager'
            - '@oro_email.provider.emailowners.provider'
            - '@oro_email.email.manager'

    oro_email.tools.email_body_helper:
        class: Oro\Bundle\EmailBundle\Tools\EmailBodyHelper
        arguments:
            - '@oro_ui.html_tag_helper'
