parameters:
    oro_user.manager.base.class:                  Oro\Bundle\UserBundle\Entity\BaseUserManager
    oro_user.manager.class:                       Oro\Bundle\UserBundle\Entity\UserManager
    oro_user.manager.api.class:                   Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
    oro_user.permission.manager.api.class:        Oro\Bundle\UserBundle\Entity\Manager\UserPermissionApiEntityManager
    oro_user.status.manager.class:                Oro\Bundle\UserBundle\Entity\Manager\StatusManager
    oro_user.entity.class:                        Oro\Bundle\UserBundle\Entity\User
    oro_user.group.entity.class:                  Oro\Bundle\UserBundle\Entity\Group
    oro_user.role.entity.class:                   Oro\Bundle\UserBundle\Entity\Role
    oro_user.security.provider.class:             Oro\Bundle\UserBundle\Security\UserProvider
    oro_user.security.login.class:                Oro\Bundle\UserBundle\EventListener\LoginSubscriber
    oro_user.twig.user_extension.class:           Oro\Bundle\UserBundle\Twig\OroUserExtension
    oro_user.user_menu.builder.class:             Oro\Bundle\UserBundle\Menu\UserMenuBuilder
    oro_user.role.listener.class:                 Oro\Bundle\UserBundle\EventListener\RoleListener
    oro_user.role.manager.class:                  Oro\Bundle\UserBundle\Entity\Manager\RoleManager
    oro_user.role.manager.api.class:              Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
    oro_user.group.manager.class:                 Oro\Bundle\UserBundle\Entity\Manager\GroupManager
    oro_user.group.manager.api.class:             Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager
    oro_user.autocomplete.user.search_handler:    Oro\Bundle\UserBundle\Autocomplete\UserSearchHandler
    oro_user.autocomplete.user.search_without_current_handler.class: Oro\Bundle\UserBundle\Autocomplete\UserWithoutCurrentHandler
    oro_user.autocomplete.user.search_acl_handler.class: Oro\Bundle\UserBundle\Autocomplete\UserAclHandler
    oro_user.autocomplete.user.organization_search_handler.class: Oro\Bundle\UserBundle\Autocomplete\OrganizationUsersHandler
    oro_user.autocomplete.role.search_handler.class: Oro\Bundle\FormBundle\Autocomplete\SearchHandler
    oro_user.autocomplete.role.authenticated_search_handler.class: Oro\Bundle\UserBundle\Autocomplete\AuthenticatedRolesHandler
    oro_user.email.owner.provider.class:          Oro\Bundle\UserBundle\Entity\Provider\EmailOwnerProvider
    oro_user.gender_provider.class:               Oro\Bundle\UserBundle\Provider\GenderProvider
    oro_user.email_recipients_provider.class:     Oro\Bundle\UserBundle\Provider\EmailRecipientsProvider
    oro_user.change_password.subscriber.class:    Oro\Bundle\UserBundle\Form\EventListener\ChangePasswordSubscriber
    oro_user.handler.delete.class:                Oro\Bundle\UserBundle\Handler\UserDeleteHandler
    oro_user.role.handler.delete.class:           Oro\Bundle\UserBundle\Handler\RoleDeleteHandler
    oro_user.activity_widget_provider.class:      %oro_activity.widget_provider.activities.menu.class%
    oro_user.event_listener.owner_user_grid_listener.class: Oro\Bundle\UserBundle\EventListener\OwnerUserGridListener
    oro_user.mailer.processor.class:              Oro\Bundle\UserBundle\Mailer\Processor
    oro_user.placeholder.filter.class:            Oro\Bundle\UserBundle\Placeholder\PlaceholderFilter
    oro_user.listener.choice_tree_filter_load_data_listener.class: Oro\Bundle\UserBundle\EventListener\ChoiceTreeFilterLoadDataListener

    oro_user.security.user_checker.class:         Oro\Bundle\UserBundle\Security\UserChecker
    oro_user.provider.filter.user_choice_tree.class: Oro\Bundle\UserBundle\Provider\Filter\ChoiceTreeUserProvider
    oro_user.provider.role_privilege_category_provider.class: Oro\Bundle\UserBundle\Provider\RolePrivilegeCategoryProvider
    oro_user.datagrid.datasource.role_permission_datasource.class: Oro\Bundle\UserBundle\Datagrid\RolePermissionDatasource
    oro_user.provider.role_privilege_capability_provider.class: Oro\Bundle\UserBundle\Provider\RolePrivilegeCapabilityProvider
    oro_user.provider.privilege_category_provider.class: Oro\Bundle\UserBundle\Provider\PrivilegeCategoryProvider

    oro_user.token.factory.wsse.class:            Oro\Bundle\UserBundle\Security\WsseTokenFactory

    oro_user.role.datagrid_helper.class:          Oro\Bundle\UserBundle\Datagrid\RoleGridHelper

    oro_user.provider.user_configuration.form_provider.class: Oro\Bundle\UserBundle\Provider\UserConfigurationFormProvider

    # Validator
    oro_user.validator.user_custom_grid_field_validator.class: Oro\Bundle\UserBundle\Validator\UserGridFieldValidator

    oro_user.imap_configuration.subscriber.class:    Oro\Bundle\UserBundle\Form\EventListener\UserImapConfigSubscriber

services:
    oro_user.manager:
        class: %oro_user.manager.class%
        arguments:
            - %oro_user.entity.class%
            - '@doctrine'
            - '@security.encoder_factory'

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

    oro_user.permission_manager.api:
        class: %oro_user.permission.manager.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_user.entity.class%
            - '@doctrine.orm.entity_manager'
            - '@security.context'
            - '@oro_security.acl.extension_selector'

    oro_user.security.provider:
        class:                        %oro_user.security.provider.class%
        public:                       false
        arguments:                    ["@oro_user.manager"]

    oro_user.security.login:
        class:                        %oro_user.security.login.class%
        arguments:                    ["@oro_user.manager"]
        tags:
            - { name: kernel.event_listener, event: security.interactive_login, method: onLogin }

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

    oro_user.user_menu:
        class:                        %oro_user.user_menu.builder.class%
        arguments:
            - '@security.context'
        tags:
            - { name: oro_menu.builder, alias: usermenu }

    oro_user.role.listener:
        class:                        %oro_user.role.listener.class%
        arguments:                    ["@oro_security.link.sid_manager"]
        tags:
            - { name: doctrine.event_listener, event: preUpdate }
            - { name: doctrine.event_listener, event: prePersist }

    oro_user.twig.user_extension:
        class:                        %oro_user.twig.user_extension.class%
        arguments:                    ["@oro_user.gender_provider", "@security.context"]
        tags:
            - { name: twig.extension }

    oro_user.status_manager:
        class:                        %oro_user.status.manager.class%
        arguments:                    ["@doctrine.orm.entity_manager", "@oro_user.manager"]

    oro_user.role_manager:
        class:                        %oro_user.role.manager.class%
        arguments:                    ["@doctrine.orm.entity_manager"]

    oro_user.role_manager.api:
        class: %oro_user.role.manager.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_user.role.entity.class%
            - '@doctrine.orm.entity_manager'

    oro_user.group_manager:
        class:                        %oro_user.group.manager.class%
        arguments:                    ["@doctrine.orm.entity_manager"]

    oro_user.group_manager.api:
        class: %oro_user.group.manager.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_user.group.entity.class%
            - '@doctrine.orm.entity_manager'

    oro_user.impersonation_authenticator:
        class: Oro\Bundle\UserBundle\Security\ImpersonationAuthenticator
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_security.token.factory.username_password_organization'
            - '@event_dispatcher'
            - '@router'

    oro_user.event_listener.impersonation_success_listener:
        class: Oro\Bundle\UserBundle\EventListener\ImpersonationSuccessListener
        arguments:
            - '@oro_user.mailer.processor'
            - '@session.flash_bag'
            - '@logger'
        tags:
            - { name: kernel.event_listener, event: oro_user.impersonation_success, method: onImpersonationSuccess }

    # Autocomplete acl user search handler
    oro_user.autocomplete.user.search_acl_handler.abstract:
        abstract: true
        class: %oro_user.autocomplete.user.search_acl_handler.class%
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_attachment.manager'
            - %oro_user.entity.class%
            - '@oro_entity_config.link.security_context'
            - '@oro_security.ownership_tree_provider'
            - "@?security.acl.voter.basic_permissions"
        calls:
            - [ setEntityNameResolver,  ['@oro_entity.entity_name_resolver']]

    oro_user.autocomplete.user.search_acl_handler:
        parent: oro_user.autocomplete.user.search_acl_handler.abstract
        calls:
            - [ setProperties, [["id", "username", "namePrefix", "firstName", "middleName", "lastName", "nameSuffix", "email"]] ]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: acl_users }
        lazy: true

    # Autocomplete search handler
    oro_user.autocomplete.user.search_handler:
        class: %oro_user.autocomplete.user.search_handler%
        parent: oro_form.autocomplete.full_name.search_handler
        arguments:
            - '@oro_attachment.manager'
            - %oro_user.entity.class%
            - ["username", "namePrefix", "firstName", "middleName", "lastName", "nameSuffix", "email"]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: users, acl_resource: oro_user_user_view }

    # Autocomplete search handler
    oro_user.autocomplete.widget_user.search_handler:
        class: Oro\Bundle\UserBundle\Autocomplete\WidgetUserSearchHandler
        parent: oro_form.autocomplete.full_name.search_handler
        arguments:
            - '@translator'
            - '@oro_attachment.manager'
            - %oro_user.entity.class%
            - ["username", "namePrefix", "firstName", "middleName", "lastName", "nameSuffix", "email"]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: widget_owner_users, acl_resource: oro_user_user_view }

    # Autocomplite search user handler limit by current organization
    oro_user.autocomplete.user.organization_search_handler:
        class: %oro_user.autocomplete.user.organization_search_handler.class%
        parent: oro_user.autocomplete.user.search_handler
        calls:
           - [setSecurityFacade,  ['@oro_security.security_facade']]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: organization_users, acl_resource: oro_user_user_view }

    oro_user.autocomplete.user.search_without_current_handler:
        class: %oro_user.autocomplete.user.search_without_current_handler.class%
        parent: oro_form.autocomplete.full_name.search_handler
        arguments:
            - '@oro_security.security_facade'
            - '@oro_attachment.manager'
            - %oro_user.entity.class%
            - ["username", "namePrefix", "firstName", "middleName", "lastName", "nameSuffix", "email"]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: users_without_current, acl_resource: oro_user_user_view }

    # Autocomplete role search handler
    oro_user.autocomplete.role.search_handler:
        class: %oro_user.autocomplete.role.search_handler.class%
        parent: oro_form.autocomplete.search_handler
        arguments:
            - %oro_user.role.entity.class%
            - ["label"]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: roles, acl_resource: oro_user_role_view }

    oro_user.autocomplete.widget_role.search_handler:
        class: Oro\Bundle\UserBundle\Autocomplete\WidgetRoleSearchHandler
        parent: oro_form.autocomplete.search_handler
        arguments:
            - %oro_user.role.entity.class%
            - ["label"]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: widget_owner_roles, acl_resource: oro_user_role_view }

    # Autocomplete role search handler for authenticated roles
    oro_user.autocomplete.role.authenticated_search_handler:
        class: %oro_user.autocomplete.role.authenticated_search_handler.class%
        parent: oro_form.autocomplete.search_handler
        arguments:
            - %oro_user.role.entity.class%
            - ["label"]
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: roles_authenticated, acl_resource: oro_user_role_view }

    oro_user.gender_provider:
        class: %oro_user.gender_provider.class%
        arguments:
            - '@translator'

    oro_user.email_recipients_provider:
        class: %oro_user.email_recipients_provider.class%
        arguments:
            - '@doctrine'
            - '@oro_email.provider.email_recipients.helper'
        tags:
            - { name: oro_email.recipients_provider, priority: 30 }

    oro_user.email.owner.provider:
        class: %oro_user.email.owner.provider.class%
        tags:
            - { name: oro_email.owner.provider, order: 1 }

    oro_user.change_password.subscriber:
        class: %oro_user.change_password.subscriber.class%
        arguments:
            - '@form.factory'
            - '@security.context'

    oro_user.handler.delete:
        class: %oro_user.handler.delete.class%
        parent: oro_soap.handler.delete.abstract
        calls:
            - [ setSecurityFacade,  ['@oro_security.security_facade'] ]

    oro_user.role.handler.delete:
        class: %oro_user.role.handler.delete.class%
        parent: oro_soap.handler.delete.abstract
        arguments:
            - '@oro_security.acl.sid_manager'

    oro_user.activity_widget_provider:
        class: %oro_user.activity_widget_provider.class%
        arguments:
           - '@oro_entity.entity_identifier_accessor'
           - '@oro_ui.twig.tab_extension'
           - 'user_activity_tab_panel'
           - %oro_user.entity.class%
        tags:
           - { name: oro_activity.activity_widget_provider, priority: -10 }

    oro_user.event_listener.owner_user_grid_listener:
        class: %oro_user.event_listener.owner_user_grid_listener.class%
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_entity_config.link.security_context'
            - '@oro_security.ownership_tree_provider'
            - "@?security.acl.voter.basic_permissions"
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.owner-users-select-grid, method: onBuildBefore }

    oro_user.mailer.processor:
        class: %oro_user.mailer.processor.class%
        arguments:
            - '@doctrine'
            - '@oro_config.global'
            - '@oro_email.email_renderer'
            - '@oro_email.email_holder_helper'
            - '@oro_email.direct_mailer'

    oro_user.placeholder.filter:
        class: %oro_user.placeholder.filter.class%
        arguments:
            - '@oro_security.security_facade'

    oro_user.password_change.widget_provider.actions:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - oro_user_password_change_button
            - oro_user_password_change_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity, priority: 100 }
            - { name: oro_ui.update_action_provider, group: activity, priority: 100 }

    oro_user.password_reset.widget_provider.actions:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - oro_user_password_reset_button
            - oro_user_password_reset_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity, priority: 110 }
            - { name: oro_ui.update_action_provider, group: activity, priority: 110 }

    security.user_checker:
        class: %oro_user.security.user_checker.class%
        arguments:
            - '@security.context.link'
            - '@session.flash_bag'
            - '@translator'

    oro_user.token.factory.wsse:
        class: %oro_user.token.factory.wsse.class%

    oro_user.role.datagrid_helper:
        class: %oro_user.role.datagrid_helper.class%
        arguments:
            - '@security.authorization_checker'

    oro_user.provider.role_entity_name:
        class: Oro\Bundle\UserBundle\Provider\RoleEntityNameProvider
        public: false
        tags:
            - { name: oro_entity.name_provider, priority: 100 }

    oro_user.provider.filter.user_choice_tree:
        class: %oro_user.provider.filter.user_choice_tree.class%
        arguments:
            - '@doctrine'
            - '@oro_security.acl_helper'
            - '@oro_locale.dql.formatter.name'

    oro_user.provider.role_privilege_category_provider:
        class: %oro_user.provider.role_privilege_category_provider.class%
        arguments:
            - '@translator'

    oro_user.provider.privilege_category_provider:
        class: %oro_user.provider.privilege_category_provider.class%
        tags:
            - { name: oro_user.privilege_category}

    oro_user.provider.role_privilege_capability_provider:
        class: %oro_user.provider.role_privilege_capability_provider.class%
        arguments:
            - '@translator'
            - '@oro_user.provider.role_privilege_category_provider'
            - '@oro_user.form.handler.abstract.acl_role='

    oro_user.datagrid.datasource.role_permission_datasource:
        class: %oro_user.datagrid.datasource.role_permission_datasource.class%
        arguments:
            - '@translator'
            - '@oro_security.acl.permission_manager'
            - '@oro_user.form.handler.abstract.acl_role='
            - '@oro_user.provider.role_privilege_category_provider'
            - '@oro_entity_config.config_manager'
        tags:
            - { name: oro_datagrid.datasource, type: role-permission-provider }

    # Validator
    oro_user.validator.user_custom_grid_field_validator:
        class: %oro_user.validator.user_custom_grid_field_validator.class%
        arguments:
            - '@oro_security.security_facade'
        tags:
            - {name: oro_entity.custom_grid_field_validator, entity_name: Oro_Bundle_UserBundle_Entity_User }

    oro_user.validator.user_authentication_fields:
        class: Oro\Bundle\UserBundle\Validator\UserAuthenticationFieldsValidator
        arguments:
            - '@oro_user.manager'
        tags:
            - { name: validator.constraint_validator, alias: oro_user.validator.user_authentication_fields }

    # Dashboard
    oro_user.dashboard.owner_helper:
        class: Oro\Bundle\UserBundle\Dashboard\OwnerHelper
        arguments:
          - '@doctrine'
          - '@security.token_storage'
          - '@oro_security.ownership_tree_provider'

    oro_user.listener.choice_tree_filter_load_data_listener:
        class: '%oro_user.listener.choice_tree_filter_load_data_listener.class%'
        arguments:
            - '@doctrine'
        tags:
            - { name: kernel.event_listener, event: oro_filter.choice_tree_filter_load_data, method: fillData }

    oro_user.provider.user_config_form_provider:
        class: %oro_user.provider.user_configuration.form_provider.class%
        arguments:
            - '@oro_config.config_bag'
            - '@form.factory'
            - '@oro_security.security_facade'
        calls:
            - [setFeatureChecker, ['@oro_featuretoggle.checker.feature_checker']]
        tags:
            -  { name: oro_config.configuration_provider }
        lazy: true

    oro_user.imap_configuration.subscriber:
        class: %oro_user.imap_configuration.subscriber.class%
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@request_stack'
            - '@security.context'
