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_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.entity.builder.class:         Oro\Bundle\EmailBundle\Builder\EmailEntityBuilder
    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.listener.entity_listener.class:     Oro\Bundle\EmailBundle\EventListener\EntityListener
    oro_email.manager.email.api.class:            Oro\Bundle\EmailBundle\Entity\Manager\EmailApiEntityManager
    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_entity.twig.extension.email.class:          Oro\Bundle\EmailBundle\Twig\EmailExtension

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

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

    # Entity config event listener
    oro_email.listener.config_subscriber.class: Oro\Bundle\EmailBundle\EventListener\ConfigSubscriber

    # 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

    # 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

    # 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
    oro_email.listener.datagrid.user_emails.main.class:   Oro\Bundle\EmailBundle\EventListener\Datagrid\MainUserEmailGridListener

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

    oro_email.listener.search_listener.class: Oro\Bundle\EmailBundle\EventListener\SearchListener

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 }

    oro_email.entity.cache.clearer:
        class: %oro_email.entity.cache.clearer.class%
        arguments:
            - %oro_email.entity.cache_dir%
            - %oro_email.entity.proxy_name_template%
        tags:
            - { name: kernel.cache_clearer }

    oro_email.email.cache.manager:
        class: %oro_email.email.cache.manager.class%
        arguments:
            - @oro_email.email_body_loader_selector
            - @doctrine.orm.entity_manager

    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.address.manager:
        class: %oro_email.email.address.manager.class%
        arguments:
            - %oro_email.entity.cache_namespace%
            - %oro_email.entity.proxy_name_template%

    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.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.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

    oro_email.listener.entity_listener:
        class: %oro_email.listener.entity_listener.class%
        arguments:
            - @oro_email.email.owner.manager
            - @oro_email.email.activity.manager
        tags:
            - { name: doctrine.event_listener, event: onFlush }

    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.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.cache']]

    # Available variables services
    oro_email.listener.config_subscriber:
        class:      %oro_email.listener.config_subscriber.class%
        arguments:  [@oro_email.cache, %oro_email.cache.available_in_template_key%]
        tags:
            - { name: kernel.event_subscriber}

    # 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
            - @doctrine
        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' ]
            # 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.provider.email
            - @oro_entity_config.provider.entity
            - @doctrine
        lazy: true
        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.global
            - @oro_locale.formatter.date_time
        lazy: true
        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_locale.formatter.name
        lazy: true
        tags:
            - { name: oro_email.emailtemplate.variable_provider, scope: system }

    oro_email.validator.email_template_syntax:
        class: Oro\Bundle\EmailBundle\Validator\EmailTemplateSyntaxValidator
        arguments:
            - @oro_email.email_renderer
            - @oro_locale.settings
            - @oro_config.user
            - @oro_entity_config.provider.entity
            - @translator
        tags:
            - { name: validator.constraint_validator, alias: oro_email.email_template_syntax_validator }

    oro_email.datagrid_query_factory:
        class: %oro_email.datagrid_query_factory.class%
        arguments:
            - @oro_email.email.owner.provider.storage
            - @oro_locale.dql.formatter.name

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

    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.owner.provider
            - @oro_email.email.activity.manager

    oro_email.workflow.action.send_email:
        class: %oro_email.workflow.action.send_email.class%
        arguments:
            - @oro_workflow.context_accessor
            - @oro_email.mailer.processor
            - @oro_email.email.address.helper
            - @oro_locale.formatter.name
        tags:
            - { name: oro_workflow.action, alias: send_email }

    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 }

    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.user_emails.main:
        class: %oro_email.listener.datagrid.user_emails.main.class%
        arguments:
            - @oro_email.helper.datagrid.emails
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.user-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
        tags:
          - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.dashboard-recent-emails-sent-grid, method: onBuildAfter }

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

    oro_email.email.activity.manager:
        class: %oro_email.email.activity.manager.class%
        arguments:
            - @oro_entity_config.provider.activity

    oro_entity.twig.extension.email:
        class: %oro_entity.twig.extension.email.class%
        arguments:
            - @oro_email.email.holder.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 }
