parameters:
    oro_customer.anonymous_customer_user.update_latency: 600 # 10 minutes in seconds
    oro_customer.anonymous_customer_user.write_connection_name: 'session'
    oro_customer.firewall_name: frontend

services:
    oro_customer.security.customer_user_provider:
        class: 'Oro\Bundle\CustomerBundle\Security\CustomerUserProvider'
        arguments:
            - "@security.authorization_checker"
            - "@oro_security.token_accessor"
            - "@oro_security.acl.manager"
        calls:
            - [setCustomerUserClass, ['Oro\Bundle\CustomerBundle\Entity\CustomerUser']]

    oro_customer.acl.voter.customer:
        class: 'Oro\Bundle\CustomerBundle\Acl\Voter\CustomerVoter'
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@security.authorization_checker'
            - '@security.authentication.trust_resolver'
            - '@Psr\Container\ContainerInterface'
        tags:
            - { name: security.voter }
            - { name: container.service_subscriber, id: oro_customer.security.customer_user_provider }
            - { name: container.service_subscriber, id: oro_customer.provider.customer_user_relations_provider }

    oro_customer.acl.voter.customer_group:
        class: 'Oro\Bundle\CustomerBundle\Acl\Voter\CustomerGroupVoter'
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@Psr\Container\ContainerInterface'
        calls:
            - [setClassName, ['Oro\Bundle\CustomerBundle\Entity\CustomerGroup']]
        tags:
            - { name: security.voter }
            - { name: container.service_subscriber, id: oro_config.global }

    oro_customer.event_listener.datagrid.customer:
        class: 'Oro\Bundle\CustomerBundle\EventListener\Datagrid\CustomerDatagridListener'
        arguments:
            - "@oro_customer.security.customer_user_provider"
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before, method: onBuildBefore }

    oro_customer.security.authentication.organization_guesser:
        class: Oro\Bundle\CustomerBundle\Security\Guesser\OrganizationGuesser
        decorates: oro_security.authentication.organization_guesser
        arguments:
            - '@.inner'
            - '@oro_frontend.request.frontend_helper'
            - '@oro_website.manager'

    oro_customer.security.authentication.trust_resolver_decorator:
        class: Oro\Bundle\CustomerBundle\Security\AuthenticationTrustResolver
        decorates: security.authentication.trust_resolver
        arguments: ['@.inner']

    Oro\Bundle\CustomerBundle\JsTree\CustomerTreeHandler:
        alias: oro_customer.customer_tree_handler

    oro_customer.customer_tree_handler:
        class: 'Oro\Bundle\CustomerBundle\JsTree\CustomerTreeHandler'
        public: true
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\Customer'
            - "@doctrine"

    oro_customer.manager.customer.api.attribute:
        class:  'Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager'
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\Customer'
            - "@doctrine.orm.entity_manager"

    oro_customer.manager.group.api.attribute:
        class:  'Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager'
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerGroup'
            - "@doctrine.orm.entity_manager"

    oro_customer.listener.search_listener:
          class: 'Oro\Bundle\CustomerBundle\EventListener\FrontendSearchListener'
          arguments:
              - '@oro_customer.owner.frontend_ownership_metadata_provider'
          tags:
              - { name: kernel.event_listener, event: oro_search.prepare_entity_map, method: prepareEntityMapEvent }
              - { name: kernel.event_listener, event: oro_search.search_mapping_collect, method: collectEntityMapEvent }

    oro_customer.form.autocomplete.customer_group.search_handler:
        parent: oro_form.autocomplete.search_handler
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerGroup'
            - ['name']
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: oro_customer_group, acl_resource: oro_customer_customer_group_view }

    oro_customer_customer.form.autocomplete.customer.search_handler:
        parent: oro_form.autocomplete.search_handler
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\Customer'
            - ['name']
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: oro_customer_customer, acl_resource: oro_customer_customer_view }

    oro_customer_customer.form.autocomplete.customer_user.search_handler:
        parent: oro_form.autocomplete.search_handler
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUser'
            - ['fullName']
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: oro_customer_user, acl_resource: oro_customer_user_view }

    oro_customer.form.autocomplete.customer_parent.search_handler:
        parent: oro_form.autocomplete.search_handler
        class: 'Oro\Bundle\CustomerBundle\Autocomplete\ParentCustomerSearchHandler'
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\Customer'
            - ['name']
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: oro_customer_parent, acl_resource: oro_customer_customer_view }

    oro_customer.form.autocomplete.customer_user_customer.search_handler:
        parent: oro_form.autocomplete.search_handler
        class: 'Oro\Bundle\CustomerBundle\Autocomplete\CustomerUserSearchHandler'
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUser'
            - ['firstname', 'lastname']
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: Oro\Bundle\CustomerBundle\Form\Type\CustomerUserType, acl_resource: oro_customer_customer_user_view }

    oro_customer.frontend_form.autocomplete.customer_user_customer.search_handler:
        parent: oro_form.autocomplete.search_handler
        class: 'Oro\Bundle\CustomerBundle\Autocomplete\CustomerUserSearchHandler'
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUser'
            - ['firstname', 'lastname']
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: Oro\Bundle\CustomerBundle\Form\Type\FrontendCustomerUserType, acl_resource: oro_customer_frontend_customer_user_view }

    oro_customer_customer.form.autocomplete.customer_user_role.search_handler:
        parent: oro_form.autocomplete.search_handler
        class: 'Oro\Bundle\CustomerBundle\Autocomplete\CustomerUserRoleSearchHandler'
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUserRole'
            - ['label']
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: customer_user_role_select_or_create_type, acl_resource: oro_customer_customer_user_role_view }

    oro_customer.customer_user.manager.api:
        class: 'Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager'
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUser'
            - "@doctrine.orm.entity_manager"

    oro_customer.datagrid.action_permission_provider:
        class: 'Oro\Bundle\CustomerBundle\Datagrid\ActionPermissionProvider'
        public: true
        arguments:
            - "@security.authorization_checker"
            - "@oro_security.token_accessor"

    oro_customer.datagrid.extension.accoun_user:
        class: 'Oro\Bundle\CustomerBundle\Datagrid\Extension\CustomerUserExtension'
        arguments:
            - '@oro_security.token_accessor'
        tags:
            - { name: oro_datagrid.extension }

    oro_customer.datagrid.extension.accoun_user_by_customer:
        class: 'Oro\Bundle\CustomerBundle\Datagrid\Extension\CustomerUserByCustomerExtension'
        calls:
            - [setRequestStack, ["@request_stack"]]
        tags:
            - { name: oro_datagrid.extension }

    oro_customer.mailer.processor:
        class: 'Oro\Bundle\CustomerBundle\Mailer\Processor'
        arguments:
            - "@oro_user.mailer.user_template_email_sender"
            - "@event_dispatcher"

    oro_customer_user.manager:
        class: 'Oro\Bundle\CustomerBundle\Entity\CustomerUserManager'
        public: true
        arguments:
            - "@oro_customer.security.user_loader"
            - "@doctrine"
            - "@security.encoder_factory"
            - "@oro_config.manager"
            - "@oro_customer_user.manager.mailer_processor_link"
            - "@oro_frontend.request.frontend_helper"
            - "@oro_locale.helper.localization"
            - "@oro_website.manager"
            - '@oro_entity_extend.enum_value_provider'
            - "@logger"

    oro_customer_user.handler.reset_password_handler:
        class: Oro\Bundle\CustomerBundle\Handler\ResetPasswordHandler
        public: true
        lazy: true
        arguments:
            - '@oro_notification.manager.email_notification'
            - '@oro_customer_user.manager'
            - '@logger'

    oro_customer_user.security.customer_user_checker:
        class: Oro\Bundle\CustomerBundle\Security\CustomerUserChecker
        decorates: security.user_checker
        arguments:
            - '@.inner'

    oro_customer_user.manager.mailer_processor_link:
        tags:
            - { name: oro_service_link, service: oro_customer.mailer.processor }

    oro_customer.security.user_loader:
        class: 'Oro\Bundle\CustomerBundle\Security\CustomerUserLoader'
        arguments:
            - '@doctrine'
            - '@oro_config.manager'
            - '@oro_security.token_accessor'
            - '@oro_website.manager'

    oro_customer.security.provider:
        class: Oro\Bundle\UserBundle\Security\UserProvider
        arguments:
            - '@oro_customer.security.user_loader'
            - '@doctrine'

    oro_customer.provider.user_logging_info_provider:
        class: Oro\Bundle\CustomerBundle\Provider\CustomerUserLoggingInfoProvider
        arguments:
            - '@request_stack'

    oro_customer.security.customer_user_login_attempts_log_listener:
        class: Oro\Bundle\CustomerBundle\EventListener\CustomerUserLoginAttemptsLogListener
        decorates: oro_user.security.login_attempts_log_listener
        arguments:
            - '@Psr\Container\ContainerInterface'
            - '@oro_frontend.request.frontend_helper'
        tags:
            - { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin }
            - { name: kernel.event_listener, event: security.authentication.failure, method: onAuthenticationFailure }
            - { name: container.service_subscriber, id: oro_user.security.login_attempts_handler, key: handler }
            - { name: container.service_subscriber, id: oro_customer.security.login_attempts_handler, key: frontend_handler }

    oro_customer.security.login_attempts_handler:
        class: Oro\Bundle\UserBundle\Security\LoginAttemptsHandler
        arguments:
            - '@oro_customer_user.manager'
            - '@oro_customer.logger.customer_user_login_attempt'
            - '@oro_user.security.skipped_log_attempts_firewalls_provider'
            - !tagged_iterator oro_security.login_source_provider.success
            - !tagged_iterator oro_security.login_source_provider.fail

    oro_customer.customer_visitor_manager:
        class: 'Oro\Bundle\CustomerBundle\Entity\CustomerVisitorManager'
        arguments:
            - '@doctrine'
            - '%oro_customer.anonymous_customer_user.write_connection_name%'

    oro_customer.customer_visitor.credentials_cookie_response_listener:
        class:  'Oro\Bundle\CustomerBundle\Security\Listener\CustomerVisitorCookieResponseListener'
        tags:
            - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }

    oro_customer.customer_visitor.update_last_visit_request_listener:
        class:  'Oro\Bundle\CustomerBundle\Security\Listener\CustomerVisitorUpdateLastVisitListener'
        arguments:
            - '@security.token_storage'
            - '%oro_customer.anonymous_customer_user.update_latency%'
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

    oro_customer.authentication.listener.anonymous_customer_user:
        class: Oro\Bundle\CustomerBundle\Security\Firewall\AnonymousCustomerUserAuthenticationListener
        abstract: true
        arguments:
            - '@security.token_storage'
            - '@security.authentication.manager'
            - '@oro_security.csrf_protected_request_helper'
            - '@oro_customer.authentication.customer_visitor_cookie_factory'
            - '@oro_customer.authentication.anonymous_customer_user_roles_provider'
            - '@oro_api.request_helper'
            - '@logger'
        tags:
            - { name: monolog.logger, channel: security }

    oro_customer.authentication.listener.api_anonymous_customer_user:
        class: Oro\Bundle\CustomerBundle\Security\Firewall\ApiAnonymousCustomerUserAuthenticationListener
        abstract: true
        arguments:
            - '@security.token_storage'
            - '@security.authentication.manager'
            - '@oro_customer.authentication.anonymous_customer_user_roles_provider'
            - '@oro_api.request_helper'
            - '@oro_config.manager'
            - '@oro_customer.authentication.decision_maker.api_anonymous_customer_user'
            - '@logger'
        tags:
            - { name: monolog.logger, channel: security }

    oro_customer.authentication.decision_maker.api_anonymous_customer_user:
        class: Oro\Bundle\CustomerBundle\Security\Firewall\ApiAnonymousCustomerUserAuthenticationDecisionMaker
        lazy: true
        arguments:
            - !abstract '$apiResources defined in Oro\Bundle\CustomerBundle\DependencyInjection\OroCustomerExtension'
            - '@oro_api.action_processor_bag'
            - '@oro_frontend.api.rest.routes'
            - '@oro_api.error_completer_registry'

    oro_customer.authentication.customer_visitor_cookie_factory:
        class: Oro\Bundle\CustomerBundle\Security\Firewall\CustomerVisitorCookieFactory
        arguments:
            - ~ #sets in Oro\Bundle\CustomerBundle\DependencyInjection\OroCustomerExtension
            - ~ #sets in Oro\Bundle\CustomerBundle\DependencyInjection\OroCustomerExtension
            - '@oro_config.manager'
            - ~ #sets in Oro\Bundle\CustomerBundle\DependencyInjection\OroCustomerExtension

    oro_customer.authentication.anonymous_customer_user_roles_provider:
        class: Oro\Bundle\CustomerBundle\Security\AnonymousCustomerUserRolesProvider
        arguments:
            - '@oro_website.manager'
            - '@doctrine'

    oro_customer.authentication.provider.anonymous_customer_user:
        class: Oro\Bundle\CustomerBundle\Security\AnonymousCustomerUserAuthenticationProvider
        abstract: true
        arguments:
            - '@oro_customer.customer_visitor_manager'
            - '@oro_website.manager'

    oro_customer.authentication.provider.api_anonymous_customer_user:
        class: Oro\Bundle\CustomerBundle\Security\ApiAnonymousCustomerUserAuthenticationProvider
        abstract: true
        arguments:
            - '@oro_website.manager'

    oro_customer.customer_user_menu:
        class: 'Oro\Bundle\CustomerBundle\Menu\CustomerUserMenuBuilder'
        tags:
            - { name: oro_menu.builder, alias: customer_usermenu }

    oro_customer.placeholder.filter:
        class: 'Oro\Bundle\CustomerBundle\Placeholder\PlaceholderFilter'
        public: true
        arguments:
            - "@oro_security.token_accessor"

    oro_customer.customer_user.password_request.handler:
        class: 'Oro\Bundle\CustomerBundle\Form\Handler\CustomerUserPasswordRequestHandler'
        arguments:
            - "@oro_customer_user.manager"
            - "@translator"
            - "@logger"

    oro_customer.customer_user.password_reset.handler:
        class: 'Oro\Bundle\CustomerBundle\Form\Handler\CustomerUserPasswordResetHandler'
        arguments:
            - '@oro_customer_user.manager'
            - '@logger'

    oro_customer.acl.voter.customer_user_role:
        class: 'Oro\Bundle\CustomerBundle\Acl\Voter\CustomerUserRoleVoter'
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@security.authorization_checker'
        calls:
            - [setClassName, ['Oro\Bundle\CustomerBundle\Entity\CustomerUserRole']]
        tags:
            - { name: security.voter, priority: 10 }

    oro_customer.customer_address.manager.api:
        class: 'Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager'
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerAddress'
            - "@doctrine.orm.entity_manager"

    oro_customer.event_listener.login:
        class: 'Oro\Bundle\CustomerBundle\EventListener\LoginListener'
        tags:
            - { name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin }

    oro_customer.event_listener.authentication_failure:
        class: Oro\Bundle\UserBundle\EventListener\AuthenticationFailureListener
        arguments:
            - 'frontend'
            - 'oro_customer.login.errors.bad_credentials'
        tags:
            - { name: kernel.event_listener, event: security.authentication.failure, method: onAuthenticationFailure, priority: -255 }

    oro_customer.acl.group_provider:
        class: 'Oro\Bundle\CustomerBundle\Acl\Group\AclGroupProvider'
        arguments:
            - '@oro_frontend.request.frontend_helper'
        tags:
            - { name: oro_security.acl.group_provider, alias: frontend_group }

    oro_customer.acl.resolver.role_translation_prefix:
        class: 'Oro\Bundle\CustomerBundle\Acl\Resolver\RoleTranslationPrefixResolver'
        public: true
        arguments:
            - "@oro_security.token_accessor"

    oro_customer.customer_user_address.manager.api:
        class: 'Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager'
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUserAddress'
            - "@doctrine.orm.entity_manager"

    oro_customer.event_listener.datagrid.customer_user:
        class: 'Oro\Bundle\CustomerBundle\EventListener\Datagrid\CustomerUserDatagridListener'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.pre.customer-customer-users-grid-update-basic, method: onBuildBefore }
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.pre.frontend-customer-customer-users-grid-update, method: onBuildBefore }

    oro_customer.twig.security_extension:
        class: 'Oro\Bundle\CustomerBundle\Twig\CustomerExtension'
        arguments:
            - "@oro_platform.twig.service_locator"
        tags:
            - { name: twig.extension }

    oro_customer.event_listener.system_config.default_customer_owner:
        class: Oro\Bundle\ConfigBundle\EventListener\EntitySystemConfigListener
        arguments:
            - '@doctrine'
            - 'Oro\Bundle\UserBundle\Entity\User'
            - 'oro_customer.default_customer_owner'
        tags:
            - { name: kernel.event_listener, event: oro_config.settings_form_preset, method: onFormPreSetData }
            - { name: kernel.event_listener, event: oro_config.settings_before_save, method: onSettingsSaveBefore }

    oro_frontend.listener.ormdatasource_acl:
        class: 'Oro\Bundle\CustomerBundle\EventListener\OrmDatasourceAclListener'
        arguments:
            - "@oro_security.token_accessor"
            - "@oro_customer.owner.frontend_ownership_metadata_provider"
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.orm_datasource.result.before, method: onResultBefore, priority: 100 }

    oro_customer.item.builder.pinbar:
        class: 'Oro\Bundle\NavigationBundle\Entity\Builder\PinbarTabBuilder'
        arguments:
            - "@doctrine.orm.entity_manager"
            - "@oro_navigation.utils.pinbar_tab_url_normalizer"
            - "@oro_navigation.provider.pinbar_tab_title"
        calls:
            - [ setClassName, ['Oro\Bundle\CustomerBundle\Entity\PinbarTab']]
            - [ setNavigationItemClassName, ['Oro\Bundle\CustomerBundle\Entity\NavigationItem']]
        tags:
            - { name: oro_navigation.item.builder, alias: frontend_pinbar }

    oro_customer.item.builder.favorite:
        class: 'Oro\Bundle\NavigationBundle\Entity\Builder\NavigationItemBuilder'
        arguments:
            - "@doctrine.orm.entity_manager"
        calls:
            - [ setClassName, ['Oro\Bundle\CustomerBundle\Entity\NavigationItem']]
        tags:
            - { name: oro_navigation.item.builder, alias: frontend_favorite }

    oro_customer.pinbar_menu.builder:
        class: 'Oro\Bundle\NavigationBundle\Menu\NavigationItemBuilder'
        arguments:
            - "@oro_security.token_accessor"
            - "@oro_navigation.provider.navigation_items"
        tags:
            - { name: oro_menu.builder, alias: frontend_pinbar }

    oro_customer.favorites_menu.builder:
        class: 'Oro\Bundle\NavigationBundle\Menu\NavigationItemBuilder'
        arguments:
            - "@oro_security.token_accessor"
            - "@oro_navigation.provider.navigation_items"
        tags:
            - { name: oro_menu.builder, alias: frontend_favorite }

    oro_customer.history_menu.builder:
        class: 'Oro\Bundle\NavigationBundle\Menu\NavigationHistoryBuilder'
        arguments:
            - '@oro_security.token_accessor'
            - '@oro_navigation.provider.navigation_items'
            - '@knp_menu.matcher'
            - '@oro_menu.manipulator'
            - '@oro_config.user'
        tags:
            - { name: oro_menu.builder, alias: frontend_history }

    oro_customer.mostviewed_menu.builder:
        class: 'Oro\Bundle\NavigationBundle\Menu\NavigationMostviewedBuilder'
        arguments:
            - '@oro_security.token_accessor'
            - '@oro_navigation.provider.navigation_items'
            - '@oro_config.user'
        tags:
            - { name: oro_menu.builder, alias: frontend_mostviewed }

    oro_customer.item.builder.history:
        class: 'Oro\Bundle\NavigationBundle\Entity\Builder\HistoryItemBuilder'
        arguments:
            - "@doctrine.orm.entity_manager"
        calls:
            - [ setClassName, ['Oro\Bundle\CustomerBundle\Entity\NavigationHistoryItem']]
        tags:
            - { name: oro_navigation.item.builder, alias: frontend_history }

    oro_customer.item.builder.mostviewed:
        class: 'Oro\Bundle\NavigationBundle\Entity\Builder\HistoryItemBuilder'
        arguments:
            - "@doctrine.orm.entity_manager"
        calls:
            - [ setClassName, ['Oro\Bundle\CustomerBundle\Entity\NavigationHistoryItem']]
        tags:
            - { name: oro_navigation.item.builder, alias: frontend_mostviewed }

    oro_customer.content_provider.menu.history_menu:
        class: 'Oro\Bundle\NavigationBundle\ContentProvider\MenuContentProvider'
        arguments:
            - "@oro_menu.twig.extension"
            - "frontend_history"
        tags:
            - { name: oro_ui.content_provider, alias: frontend_history }

    oro_customer.content_provider.menu.mostviewed_menu:
        class: 'Oro\Bundle\NavigationBundle\ContentProvider\MenuContentProvider'
        arguments:
            - "@oro_menu.twig.extension"
            - "frontend_mostviewed"
        tags:
            - { name: oro_ui.content_provider, alias: frontend_mostviewed }

    oro_customer.delete_handler_extension.customer_user:
        class: Oro\Bundle\CustomerBundle\Handler\CustomerUserDeleteHandlerExtension
        parent: oro_entity.delete_handler_extension
        arguments:
            - '@oro_security.token_accessor'
            - '@oro_organization.owner_deletion_manager'
        tags:
            - { name: oro_entity.delete_handler_extension, entity: Oro\Bundle\CustomerBundle\Entity\CustomerUser }

    oro_customer.discriminator_map_listener:
        class: 'Oro\Bundle\EntityBundle\ORM\DiscriminatorMapListener'
        calls:
            - [ addClass, ['oro_audit', 'Oro\Bundle\CustomerBundle\Entity\Audit'] ]
            - [ addClass, ['oro_grid_view', 'Oro\Bundle\CustomerBundle\Entity\GridView'] ]
            - [ addClass, ['oro_grid_view_user_rel', 'Oro\Bundle\CustomerBundle\Entity\GridViewUser'] ]
        tags:
            - { name: doctrine.event_listener, event: loadClassMetadata }

    oro_customer.event_listener.frontend_dataaudit_history_grid_listener:
        class: 'Oro\Bundle\DataAuditBundle\EventListener\AuditHistoryGridListener'
        arguments:
            - [objectClass, objectId]
        tags:
          - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.frontend-audit-history-grid, method: onBuildAfter }

    oro_customer.provider.frontend_customer_user_registration_form:
        class: 'Oro\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerUserRegistrationFormProvider'
        public: true
        arguments:
            - "@form.factory"
            - "@oro_config.manager"
            - "@oro_website.manager"
            - "@doctrine"
            - '@router'
        tags:
            - { name: layout.data_provider, alias: oro_customer_frontend_customer_user_register }

    oro_customer.manager.windows_state:
        class: Oro\Bundle\WindowsBundle\Manager\WindowsStateManager
        arguments:
            - '@security.token_storage'
            - '@doctrine'
            - '@oro_windows.manager.windows_state_request'
            - 'Oro\Bundle\CustomerBundle\Entity\WindowsState'
        tags:
            - { name: oro_windows.windows_state_manager, user_class: Oro\Bundle\CustomerBundle\Entity\CustomerUser }

    oro_customer.provider.current_user:
        class: Oro\Bundle\CustomerBundle\Layout\DataProvider\CurrentUserProvider
        arguments:
            - '@security.token_storage'
        tags:
            - { name: layout.data_provider, alias: current_user }

    oro_customer.provider.sign_in:
        class: 'Oro\Bundle\CustomerBundle\Layout\DataProvider\SignInProvider'
        arguments:
            - "@request_stack"
            - "@oro_security.token_accessor"
            - "@security.csrf.token_manager"
            - "@oro_customer.provider.sign_in.target_path"
            - "@translator"
        tags:
            - { name: layout.data_provider, alias: oro_customer_sign_in }

    oro_customer.provider.sign_in.target_path:
        class: 'Oro\Bundle\CustomerBundle\Layout\DataProvider\SignInTargetPathProvider'

    oro_customer.doctrine.filters_listener:
        class: 'Oro\Bundle\CustomerBundle\Doctrine\DoctrineFiltersListener'
        arguments:
            - "@doctrine"
            - "@oro_frontend.request.frontend_helper"
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onRequest }

    oro_customer.provider.frontend_customer_user_role_form:
        class: 'Oro\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerUserRoleFormProvider'
        arguments:
            - '@form.factory'
            - '@oro_customer.form.handler.update_customer_user_role_frontend'
            - '@router'
        tags:
            - { name: layout.data_provider, alias: oro_customer_frontend_customer_user_role_form }

    Oro\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerUserAddressFormProvider:
        alias: oro_customer.provider.fronted_customer_user_address_form

    oro_customer.provider.fronted_customer_user_address_form:
        class: Oro\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerUserAddressFormProvider
        public: true
        arguments:
            - '@form.factory'
            - '@router'
        tags:
            - { name: layout.data_provider, alias: oro_customer_frontend_customer_user_address_form }

    Oro\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerAddressFormProvider:
        alias: oro_customer.provider.frontend_customer_address_form

    oro_customer.provider.frontend_customer_address_form:
        class: Oro\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerAddressFormProvider
        public: true
        arguments:
            - '@form.factory'
            - '@router'
        tags:
            - { name: layout.data_provider, alias: oro_customer_frontend_customer_address_form }

    oro_customer.provider.frontend_customer_user_form:
        class: 'Oro\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerUserFormProvider'
        arguments:
              - '@form.factory'
              - '@router'
        tags:
            - { name: layout.data_provider, alias: oro_customer_frontend_customer_user_form }

    oro_customer.provider.customer_user_relations_provider:
        class: 'Oro\Bundle\CustomerBundle\Provider\CustomerUserRelationsProvider'
        arguments:
            - '@oro_config.global'
            - '@oro_entity.doctrine_helper'

    oro_customer.provider.fronted_customer_user_role_capability_set_options:
        class: 'Oro\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerUserRoleCapabilitySetOptionsProvider'
        arguments:
            - '@oro_customer.provider.role_privilege_capability_provider'
            - '@oro_user.provider.role_privilege_category_provider'
        tags:
            - { name: layout.data_provider, alias: oro_customer_fronted_customer_user_role_capability_set_options }

    oro_customer.provider.fronted_customer_user_role_tab_options:
        class: 'Oro\Bundle\CustomerBundle\Layout\DataProvider\FrontendCustomerUserRoleTabOptionsProvider'
        shared: false
        arguments:
            - '@oro_user.provider.role_privilege_category_provider'
            - '@translator'
            - '@oro_customer.form.handler.update_customer_user_role_frontend'
        tags:
            - { name: layout.data_provider, alias: oro_customer_fronted_customer_user_role_tab_options }

    oro_customer.provider.role_privilege_capability_provider:
        class: Oro\Bundle\UserBundle\Provider\RolePrivilegeCapabilityProvider
        arguments:
            - '@translator'
            - '@oro_user.provider.role_privilege_category_provider'
            - '@oro_customer.form.handler.update_customer_user_role_frontend'

    oro_customer.datagrid.datasource.customer_role_frontend_permission_datasource:
        class: 'Oro\Bundle\CustomerBundle\Datagrid\RolePermissionDatasource'
        arguments:
            - '@translator'
            - '@oro_security.acl.permission_manager'
            - '@oro_customer.form.handler.update_customer_user_role_frontend'
            - '@oro_user.provider.role_privilege_category_provider'
            - '@oro_entity_config.config_manager'
            - '@oro_customer.acl.resolver.role_translation_prefix'
        tags:
            - { name: oro_datagrid.datasource, type: customer-role-frontend-permission-provider }

    oro_customer.datagrid.datasource.customer_role_permission_datasource:
        class: 'Oro\Bundle\CustomerBundle\Datagrid\RolePermissionDatasource'
        arguments:
            - '@translator'
            - '@oro_security.acl.permission_manager'
            - '@oro_customer.form.handler.update_customer_user_role'
            - '@oro_user.provider.role_privilege_category_provider'
            - '@oro_entity_config.config_manager'
            - '@oro_customer.acl.resolver.role_translation_prefix'
        tags:
            - { name: oro_datagrid.datasource, type: customer-role-permission-provider }

    oro_customer.layout.data_provider.address_provider_abstract:
        class: Oro\Bundle\CustomerBundle\Layout\DataProvider\AddressProvider
        arguments:
            - '@router'
            - '@fragment.handler'
            - '@oro_config.manager'

    oro_customer.layout.data_provider.customer_address_provider:
        parent: oro_customer.layout.data_provider.address_provider_abstract
        calls:
            - [setEntityClass, ['Oro\Bundle\CustomerBundle\Entity\Customer']]
            - [setListRouteName, ['oro_api_customer_frontend_get_customer_addresses']]
            - [setDeleteRouteName, ['oro_api_customer_frontend_delete_customer_address']]
            - [setCreateRouteName, ['oro_customer_frontend_customer_address_create']]
            - [setUpdateRouteName, ['oro_customer_frontend_customer_address_update']]
        tags:
            - { name: layout.data_provider, alias: customer_address_provider }

    oro_customer.layout.data_provider.customer_user_address_provider:
        parent: oro_customer.layout.data_provider.address_provider_abstract
        calls:
            - [setEntityClass, ['Oro\Bundle\CustomerBundle\Entity\CustomerUser']]
            - [setListRouteName, ['oro_api_customer_frontend_get_customeruser_addresses']]
            - [setDeleteRouteName, ['oro_api_customer_frontend_delete_customeruser_address']]
            - [setCreateRouteName, ['oro_customer_frontend_customer_user_address_create']]
            - [setUpdateRouteName, ['oro_customer_frontend_customer_user_address_update']]
        tags:
            - { name: layout.data_provider, alias: customer_user_address_provider }

    oro_customer.layout.data_provider.customer_user_default_address_provider:
        parent: oro_customer.layout.data_provider.address_provider_abstract
        calls:
            - [setEntityClass, ['Oro\Bundle\CustomerBundle\Entity\CustomerUser']]
            - [setListRouteName, ['oro_api_customer_frontend_get_customeruser_addresses', true]]
            - [setDeleteRouteName, ['oro_api_customer_frontend_delete_customeruser_address']]
            - [setCreateRouteName, ['oro_customer_frontend_customer_user_address_create']]
            - [setUpdateRouteName, ['oro_customer_frontend_customer_user_address_update']]
        tags:
            - { name: layout.data_provider, alias: customer_user_default_address_provider }

    oro_customer.customer_scope_criteria_provider:
        class: 'Oro\Bundle\CustomerBundle\Provider\ScopeCustomerCriteriaProvider'
        arguments:
            - "@security.token_storage"
        tags:
            - { name: oro_scope.provider, scopeType: customer_category_visibility, priority: 30 }
            - { name: oro_scope.provider, scopeType: customer_product_visibility, priority: 30 }
            - { name: oro_scope.provider, scopeType: web_content, priority: 250 }
            - { name: oro_scope.provider, scopeType: cms_content_block, priority: 250 }
            - { name: oro_scope.provider, scopeType: website_search_term, priority: 250 }
            - { name: oro_scope.provider, scopeType: workflow_definition, priority: 30 }

    oro_customer.anonymous_customer_scope_criteria_provider:
        class: 'Oro\Bundle\CustomerBundle\Provider\ScopeAnonymousCustomerGroupCriteriaProvider'
        arguments:
            - '@oro_customer.provider.customer_user_relations_provider'
        tags:
            - { name: oro_scope.provider, scopeType: web_content_for_sitemap, priority: 250 }

    oro_customer.customer_group_scope_criteria_provider:
        class: 'Oro\Bundle\CustomerBundle\Provider\ScopeCustomerGroupCriteriaProvider'
        arguments:
            - "@security.token_storage"
            - "@oro_customer.provider.customer_user_relations_provider"
        tags:
            - { name: oro_scope.provider, scopeType: customer_group_category_visibility, priority: 30 }
            - { name: oro_scope.provider, scopeType: customer_group_product_visibility, priority: 30 }
            - { name: oro_scope.provider, scopeType: web_content, priority: 100 }
            - { name: oro_scope.provider, scopeType: cms_content_block, priority: 100 }
            - { name: oro_scope.provider, scopeType: website_search_term, priority: 100 }
            - { name: oro_scope.provider, scopeType: workflow_definition, priority: 20 }

    oro_customer.customer_user_scope_cache_key_builder:
        class: Oro\Bundle\CustomerBundle\Provider\CustomerUserScopeCacheKeyBuilder
        decorates: oro_scope.scope_cache_key_builder
        decoration_priority: 90
        arguments:
            - '@.inner'
            - '@security.token_storage'
            - '@oro_website.manager'
            - '@oro_frontend.request.frontend_helper'

    oro_customer.customer_role.listener:
        class: Oro\Bundle\UserBundle\EventListener\RoleListener
        arguments:
            - '@oro_security.acl.sid_manager'
        tags:
            - { name: doctrine.orm.entity_listener, entity: Oro\Bundle\CustomerBundle\Entity\CustomerUserRole, event: prePersist}
            - { name: doctrine.orm.entity_listener, entity: Oro\Bundle\CustomerBundle\Entity\CustomerUserRole, event: preUpdate}

    oro_customer.entity_ownership.listener:
        class: Oro\Bundle\CustomerBundle\EventListener\RecordOwnerDataListener
        arguments:
            - '@oro_customer.security.customer_user_provider'
            - '@oro_entity_config.config_manager'
            - '@property_accessor'
        tags:
             - { name: doctrine.event_listener, event: prePersist }

    oro_customer.event_listener.role_page_listener:
        class: Oro\Bundle\CustomerBundle\EventListener\CustomerRolePageListener
        arguments:
            - '@translator'
            - '@request_stack'
        tags:
            - { name: kernel.event_listener, event: entity_form.render.before, method: onUpdatePageRender }
            - { name: kernel.event_listener, event: entity_view.render.before, method: onViewPageRender }

    oro_customer.datagrid.datasource.workflow_permission_datasource:
        class: Oro\Bundle\CustomerBundle\Datagrid\WorkflowPermissionDatasource
        arguments:
            - '@translator'
            - '@oro_security.acl.permission_manager'
            - '@oro_customer.form.handler.update_customer_user_role'
            - '@oro_user.provider.role_privilege_category_provider'
            - '@oro_entity_config.config_manager'
            - '@oro_customer.acl.resolver.role_translation_prefix'
        tags:
            - { name: oro_datagrid.datasource, type: customer-user-workflow-permission-grid-provider }

    oro_user.provider.role_privilege_capability_provider_commerce:
        class: Oro\Bundle\UserBundle\Provider\RolePrivilegeCapabilityProvider
        public: true
        arguments:
            - '@translator'
            - '@oro_user.provider.role_privilege_category_provider'
            - '@oro_customer.form.handler.acl_role.commerce'

    oro_customer.provider.role_privilege_capability_provider.decorator:
        class: Oro\Bundle\UserBundle\Provider\RolePrivilegeCapabilityProvider
        decorates: oro_user.provider.role_privilege_capability_provider
        arguments:
            - '@translator'
            - '@oro_user.provider.role_privilege_category_provider'
            - '@oro_customer.form.handler.acl_role.backend'

    oro_customer.customer_id.placeholder:
        class: 'Oro\Bundle\CustomerBundle\Placeholder\CustomerIdPlaceholder'
        arguments:
            - '@security.token_storage'
        tags:
            - { name: website_search.placeholder }

    oro_customer.customer_user_id.placeholder:
        class: 'Oro\Bundle\CustomerBundle\Placeholder\CustomerUserIdPlaceholder'
        arguments:
            - '@security.token_storage'
        tags:
            - { name: website_search.placeholder }

    oro_customer.validator.frontend_owner:
        class: Oro\Bundle\CustomerBundle\Validator\Constraints\FrontendOwnerValidator
        arguments:
            - '@doctrine'
            - '@oro_customer.owner.frontend_ownership_metadata_provider'
            - '@security.authorization_checker'
            - '@oro_security.token_accessor'
            - '@oro_security.ownership_tree_provider.chain'
            - '@security.acl.voter.basic_permissions'
            - '@oro_security.acl.group_provider.chain'
        tags:
            - { name: validator.constraint_validator, alias: frontend_owner_validator }

    oro_customer.validator.customer_without_role:
        class: Oro\Bundle\CustomerBundle\Validator\Constraints\CustomerUserWithoutRoleValidator
        tags:
            - { name: validator.constraint_validator }

    oro_customer.validator.customer_check_role:
        class: Oro\Bundle\CustomerBundle\Validator\Constraints\CustomerUserCheckRoleValidator
        tags:
            - { name: validator.constraint_validator }

    oro_customer.customer_user.validator.unique_name_and_email:
        class: Oro\Bundle\CustomerBundle\Validator\Constraints\UniqueCustomerUserNameAndEmailValidator
        arguments:
            - '@oro_customer_user.manager'
        tags:
            - { name: validator.constraint_validator, alias: oro_customer.customer_user.validator.unique_name_and_email }

    oro_customer.validator.email_case_insensitive_option:
        class: Oro\Bundle\CustomerBundle\Validator\Constraints\EmailCaseInsensitiveOptionValidator
        arguments:
            - '@doctrine'
            - '@translator'
            - '@oro_datagrid.helper.route'
        tags:
            - { name: validator.constraint_validator }

    oro_customer.grid_view.manager.api:
        class: 'Oro\Bundle\DataGridBundle\Entity\Manager\GridViewApiEntityManager'
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\CustomerBundle\Entity\GridView'
            - '@doctrine.orm.entity_manager'
            - '@oro_datagrid.grid_view.manager'

    oro_customer.grid_view.manager:
        parent: oro_datagrid.grid_view.manager
        calls:
            - [setGridViewClassName, ['Oro\Bundle\CustomerBundle\Entity\GridView']]
            - [setGridViewUserClassName, ['Oro\Bundle\CustomerBundle\Entity\GridViewUser']]

    oro_customer.grid_view.manager.composite:
        class: 'Oro\Bundle\CustomerBundle\Entity\Manager\GridViewManagerComposite'
        decorates: oro_datagrid.grid_view.manager
        arguments:
            - '@.inner'
            - '@oro_customer.grid_view.manager'
            - '@oro_security.token_accessor'

    oro_customer.extension.views:
        class: 'Oro\Bundle\CustomerBundle\Datagrid\Extension\GridViewsExtension'
        parent: oro_datagrid.extension.views

    oro_customer.extension.views.composite:
        class: 'Oro\Bundle\CustomerBundle\Datagrid\Extension\GridViewsExtensionComposite'
        decorates: oro_datagrid.extension.views
        arguments:
            - '@.inner'
            - '@oro_customer.extension.views'
            - '@oro_security.token_accessor'
        tags:
            - { name: oro_datagrid.extension }

    oro_customer.event_listener.navigation:
        class: 'Oro\Bundle\CustomerBundle\EventListener\NavigationListener'
        arguments:
            - "@security.authorization_checker"
        tags:
            - { name: kernel.event_listener, event: oro_menu.configure.oro_customer_menu, method: onNavigationConfigure }

    oro_customer.datagrid.extension.mass_action.handler.delete:
        parent: oro_datagrid.extension.mass_action.handler.delete
        public: true
        class: Oro\Bundle\CustomerBundle\Datagrid\Extension\MassAction\CustomersDeleteActionHandler
        calls:
            - [setTokenAccessor, ['@oro_security.token_accessor']]

    oro_customer.datagrid.mass_action.customers_enable_switch.handler.disable:
        class: Oro\Bundle\CustomerBundle\Datagrid\Extension\MassAction\CustomersEnableSwitchActionHandler
        public: true
        shared: false
        arguments:
            - '@oro_security.acl_helper'
            - '@security.token_storage'
            - '@translator'
            - false
            - 'oro.customer.mass_actions.disable_customers.success_message'
            - 'oro.customer.mass_actions.disable_customers.error_message'

    oro_customer.datagrid.mass_action.customers_enable_switch.handler.enable:
        class: Oro\Bundle\CustomerBundle\Datagrid\Extension\MassAction\CustomersEnableSwitchActionHandler
        public: true
        shared: false
        arguments:
            - '@oro_security.acl_helper'
            - '@security.token_storage'
            - '@translator'
            - true
            - 'oro.customer.mass_actions.enable_customers.success_message'
            - 'oro.customer.mass_actions.enable_customers.error_message'

    oro_customer.datagrid.mass_action.disable_customers:
        class: Oro\Bundle\DataGridBundle\Extension\MassAction\Actions\Ajax\AjaxMassAction
        shared: false
        tags:
            - { name: oro_datagrid.extension.mass_action.type, type: disablecustomers }

    oro_customer.datagrid.mass_action.enable_customers:
        class: Oro\Bundle\DataGridBundle\Extension\MassAction\Actions\Ajax\AjaxMassAction
        shared: false
        tags:
            - { name: oro_datagrid.extension.mass_action.type, type: enablecustomers }

    oro_customer.validation.constraint.circular_customer_reference_validator:
        class: Oro\Bundle\CustomerBundle\Validator\Constraints\CircularCustomerReferenceValidator
        arguments:
            - '@oro_customer.owner.tree_provider'
        tags:
            - { name: validator.constraint_validator, alias: parent_customer_validator }

    oro_customer.event_listener.disabled_user_session_listener:
        class: Oro\Bundle\CustomerBundle\EventListener\DisabledUserSessionListener
        arguments:
            - '@security.logout_url_generator'
            - '@oro_frontend.request.frontend_helper'
        tags:
            - { name: kernel.event_listener, event: kernel.exception, method: onKernelException }

    oro_customer.delete_handler_extension.customer:
        class: Oro\Bundle\CustomerBundle\Handler\CustomerDeleteHandlerExtension
        parent: oro_entity.delete_handler_extension
        arguments:
            - '@oro_customer.customer.assign.helper'
        tags:
            - { name: oro_entity.delete_handler_extension, entity: Oro\Bundle\CustomerBundle\Entity\Customer }

    oro_customer.customer.mass_action.handler.delete:
        class: Oro\Bundle\CustomerBundle\Handler\CustomersDeleteMassActionHandler
        public: true
        parent: oro_datagrid.extension.mass_action.handler.delete
        calls:
           - [setCustomerAssignHelper, ['@oro_customer.customer.assign.helper']]

    oro_customer.customer.assign.helper:
        class: Oro\Bundle\CustomerBundle\Handler\CustomerAssignHelper
        arguments:
            - '@oro_entity.doctrine_helper'
        calls:
            - [addIgnoredRelation, ['Oro\Bundle\CustomerBundle\Entity\Customer', 'parent']]
            - [addPriorityRelation, ['Oro\Bundle\CustomerBundle\Entity\CustomerUser']]
            - [addPriorityRelation, ['Oro\Bundle\CustomerBundle\Entity\Customer']]
            - [addPriorityRelation, ['Oro\Bundle\CustomerBundle\Entity\CustomerUserRole']]

    Oro\Bundle\CustomerBundle\Provider\FrontendAddressProvider:
        alias: oro_customer.provider.frontend.address

    oro_customer.provider.frontend.address:
        class: 'Oro\Bundle\CustomerBundle\Provider\FrontendAddressProvider'
        public: true
        arguments:
            - '@doctrine'
            - '@oro_security.acl_helper'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerAddress'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUserAddress'

    oro_customer.datagrid.frontend_customer_address.action_checker:
        class: Oro\Bundle\CustomerBundle\Datagrid\FrontendCustomerAddressActionChecker
        public: true
        arguments:
            - '@oro_config.manager'

    oro_customer.voter.anonymous_customer_user:
        class: 'Oro\Bundle\CustomerBundle\Voter\AnonymousCustomerUserVoter'
        arguments:
           - '@oro_featuretoggle.voter.config_voter'
           - '@security.token_storage'
        abstract: true

    oro_customer.action.get_or_create_active_user:
        class: Oro\Bundle\CustomerBundle\Action\GetActiveUserOrNull
        arguments:
            - '@oro_action.expression.context_accessor'
            - '@security.token_storage'
        tags:
            - { name: oro_action.action, alias: get_active_user_or_null }

    oro_customer.action.get_active_visitor:
        class: Oro\Bundle\CustomerBundle\Action\GetActiveVisitor
        arguments:
            - '@oro_action.expression.context_accessor'
            - '@security.token_storage'
        tags:
            - { name: oro_action.action, alias: get_active_visitor }

    oro_customer.condition.customer_has_assignments:
        class: 'Oro\Bundle\CustomerBundle\Condition\CustomerHasAssignments'
        arguments:
            - '@oro_customer.customer.assign.helper'
        tags:
            - { name: oro_action.condition, alias: customer_has_assignments }

    oro_customer.manager.guest_customer_user:
        class: Oro\Bundle\CustomerBundle\Entity\GuestCustomerUserManager
        public: true
        lazy: true
        arguments:
            - '@oro_website.manager'
            - '@oro_customer_user.manager'
            - '@oro_customer.provider.customer_user_relations_provider'
            - '@oro_user.provider.default_user'
            - '@property_accessor'

    oro_customer.voter.customer_user:
        class: 'Oro\Bundle\CustomerBundle\Voter\CustomerUserVoter'
        arguments:
           - '@oro_security.token_accessor'
        abstract: true

    oro_customer.event_listener.navigation_items:
        parent: oro_navigation.event_listener.navigation_items
        tags:
            - { name: kernel.event_listener, event: oro_menu.configure.oro_customer_menu, method: onNavigationConfigure }

    oro_customer.security.login_manager:
        class: Oro\Bundle\CustomerBundle\Security\LoginManager
        public: true
        arguments:
           - '@security.token_storage'
           - ~ # UserCheckerInterface $userChecker
           - '@security.authentication.session_strategy'
           - '@request_stack'
           - '@oro_security.token.factory.username_password_organization'
           - '@event_dispatcher'
           - ~ # remember-me services

    oro_customer.security.user_checker.decorator:
        decorates: security.user_checker
        class: Oro\Bundle\CustomerBundle\Security\UserChecker
        arguments:
            - '@.inner'

    oro_customer.handler.frontend_customer_user_handler:
        class: 'Oro\Bundle\CustomerBundle\Form\Handler\FrontendCustomerUserHandler'
        arguments:
            - '@oro_form.event.event_dispatcher'
            - '@oro_entity.doctrine_helper'
            - '@oro_website.request_website_provider'
            - '@oro_customer_user.manager'

    oro_customer.event_listener.auto_login:
        class: Oro\Bundle\CustomerBundle\EventListener\AuthenticationListener
        arguments:
            - '@oro_customer.security.login_manager'
            - '@oro_config.manager'
            - '%oro_customer.firewall_name%'
        lazy: true
        tags:
            - { name: kernel.event_subscriber}

    oro_customer.security.orm.ownership_sql_walker_builder:
        class: 'Oro\Bundle\CustomerBundle\ORM\Walker\CustomerOwnershipConditionDataBuilder'
        decorates: 'oro_security.orm.ownership_sql_walker_builder'
        decoration_priority: -20
        arguments:
            - '@security.authorization_checker'
            - '@security.token_storage'
            - '@oro_security.owner.metadata_provider.chain'
            - '@oro_security.ownership_tree_provider.chain'
            - '@security.acl.voter.basic_permissions'
            - '@.inner'
            - '@oro_security.acl.group_provider.chain'

    oro_customer.handler.customer_registration_handler:
        class: Oro\Bundle\CustomerBundle\Handler\CustomerRegistrationHandler
        arguments:
            - '@oro_customer.provider.frontend_customer_user_registration_form'
            - '@oro_customer_user.manager'
            - '@oro_customer.handler.frontend_customer_user_handler'
            - '@oro_form.update_handler'
            - '@translator'

    oro_customer.handler.forgot_password:
        class: 'Oro\Bundle\CustomerBundle\Handler\ForgotPasswordHandler'
        lazy: true
        arguments:
            - '@oro_customer.customer_user.password_request.handler'
            - '@oro_customer.provider.frontend_customer_user_form'
            - '@session'

    oro_customer.website_access_rule_walker_context_factory:
        class: Oro\Bundle\WebsiteBundle\Acl\ORM\Walker\WebsiteAccessRuleWalkerContextFactory
        decorates: oro_security.access_rule_walker_context_factory
        arguments:
            - '@.inner'
            - '@oro_website.manager'

    oro_customer.frontend_access_rule_walker_context_factory:
        class: Oro\Bundle\CustomerBundle\Acl\ORM\Walker\FrontendAccessRuleWalkerContextFactory
        decorates: oro_security.access_rule_walker_context_factory
        decoration_priority: 100
        arguments:
            - '@.inner'
            - '@oro_frontend.request.frontend_helper'

    oro_customer.access_rule.self_managed_public_customer_user_role:
        class: Oro\Bundle\CustomerBundle\Acl\AccessRule\SelfManagedPublicCustomerUserRoleAccessRule
        arguments:
            - '@oro_security.token_accessor'
        tags:
            - { name: oro_security.access_rule, priority: -255, entityClass: Oro\Bundle\CustomerBundle\Entity\CustomerUserRole, loggedUserClass: Oro\Bundle\CustomerBundle\Entity\CustomerUser }

    oro_customer.provider.customer_user_preferred_localization_provider:
        class: 'Oro\Bundle\CustomerBundle\Provider\CustomerUserPreferredLocalizationProvider'
        arguments:
            - '@oro_frontend_localization.manager.user_localization'
        tags:
            - { name: oro_locale.preferred_localization_provider }

    oro_customer.updater.customer_user_reassign_updater:
        class: 'Oro\Bundle\CustomerBundle\Handler\CustomerUserReassignUpdater'
        arguments:
            - !tagged_iterator oro_customer.updater.customer_user_reassign

    oro_customer.event_listener.customer_user_reassign:
        class: 'Oro\Bundle\CustomerBundle\EventListener\CustomerUserReassignEventListener'
        arguments:
            - '@oro_customer.updater.customer_user_reassign_updater'
        tags:
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\CustomerBundle\Entity\CustomerUser', event: preUpdate }

    oro_customer.validator.customer_user_related_entities_validator:
        class: Oro\Bundle\CustomerBundle\Validator\Constraints\CustomerRelatedEntitiesValidator
        arguments:
            - '@security.authorization_checker'
            - '@oro_customer.updater.customer_user_reassign_updater'
            - '@doctrine'
            - '@oro_entity.entity_class_name_provider'
        tags:
            - { name: validator.constraint_validator }

    oro_customer.updater.customer_user_reassign.abstract:
        class: 'Oro\Bundle\CustomerBundle\Handler\CustomerUserReassignEntityUpdater'
        arguments:
            - '@doctrine'
            - '@oro_dataaudit.converter.entity_to_entity_change_array'
            - '@oro_dataaudit.provider.audit_message_body_provider'
            - '@oro_message_queue.message_producer'
            - '@security.token_storage'
        abstract: true

    oro_customer.acl.permission_granting_strategy:
        class: Oro\Bundle\CustomerBundle\Acl\Domain\PermissionGrantingStrategy
        decorates: oro_security.acl.permission_granting_strategy
        arguments:
            - '@.inner'

    oro_customer.filter.privilege_entity_filter.grid_view:
        class: 'Oro\Bundle\SecurityBundle\Filter\AclPrivilegeEntityByConfigurableNameFilter'
        arguments:
            - 'default'
            - ['Oro\Bundle\CustomerBundle\Entity\GridView']
        tags:
            - { name: oro.security.filter.acl_privilege, priority: 100 }

    oro_customer.email.owner.provider:
        class: Oro\Bundle\CustomerBundle\Entity\Provider\EmailOwnerProvider
        tags:
            - { name: oro_email.owner.provider, order: 4 }

    oro_customer.email_recipients_provider:
        class: Oro\Bundle\CustomerBundle\Provider\EmailRecipientsProvider
        arguments:
            - '@doctrine'
            - '@oro_email.provider.email_recipients.helper'
        tags:
            - { name: oro_email.recipients_provider, priority: 40 }

    oro_customer.event_listener.preferred_localization_form_view:
        class: Oro\Bundle\CustomerBundle\EventListener\PreferredLocalizationFormViewListener
        arguments:
            - '@oro_website.manager'
        tags:
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.customer-user-edit, method: onEntityEdit }
            - { name: kernel.event_listener, event: oro_ui.scroll_data.before.customer-user-view, method: onEntityView }

    oro_customer.listener.email_body_add:
        class: Oro\Bundle\CustomerBundle\EventListener\EmailBodyAddListener
        arguments:
            - '@doctrine'
            - '@oro_email.email.activity.manager'
        tags:
            - { name: kernel.event_listener, event: oro_email.email_body_added, method: linkToCustomerUser }

    oro_customer.provider.customer_config_form_provider:
        class: Oro\Bundle\CustomerBundle\Provider\CustomerConfigurationFormProvider
        parent: oro_config.provider.abstract_provider
        lazy: true

    oro_customer.provider.customer_group_config_form_provider:
        class: Oro\Bundle\CustomerBundle\Provider\CustomerGroupConfigurationFormProvider
        parent: oro_config.provider.abstract_provider
        lazy: true

    Oro\Bundle\CustomerBundle\Provider\CustomerConfigurationFormProvider:
        alias: oro_customer.provider.customer_config_form_provider

    Oro\Bundle\CustomerBundle\Provider\CustomerGroupConfigurationFormProvider:
        alias: oro_customer.provider.customer_group_config_form_provider

    oro_customer.scope.customer:
        class: Oro\Bundle\CustomerBundle\Config\CustomerScopeManager
        parent: oro_config.scope_manager.abstract
        calls:
            - [setTokenStorage, [ '@security.token_storage' ]]
        tags:
            - { name: oro_config.scope, scope: customer, priority: 290 }

    oro_customer.scope.customer_group:
        class: Oro\Bundle\CustomerBundle\Config\CustomerGroupScopeManager
        parent: oro_config.scope_manager.abstract
        calls:
            - [setTokenStorage, [ '@security.token_storage' ]]
        tags:
            - { name: oro_config.scope, scope: customer_group, priority: 280 }

    oro_customer.event_listener.customer_grid_listener:
        class: Oro\Bundle\CustomerBundle\EventListener\Datagrid\CustomerConfigurationDatagridListener
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.customer-customers-grid, method: onBuildBefore }

    oro_customer.event_listener.customer_group_grid_listener:
        class: Oro\Bundle\CustomerBundle\EventListener\Datagrid\CustomerGroupConfigurationDatagridListener
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.customer-groups-grid, method: onBuildBefore }

    oro_customer.datagrid.event_listener.enabled_localizations_grid:
        class: Oro\Bundle\CustomerBundle\EventListener\EnabledLocalizationsGridListener
        arguments:
            - '@oro_config.manager'
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.enabled-localizations-select-grid, method: onBuildAfter }

    oro_customer.autocomplete.enabled_localizations.search_handler:
        parent: oro_form.autocomplete.search_handler
        class: Oro\Bundle\CustomerBundle\Autocomplete\EnabledLocalizationsSearchHandler
        arguments:
            - 'Oro\Bundle\LocaleBundle\Entity\Localization'
            - ['name']
            - '@oro_config.manager'
            - '@doctrine'
        tags:
            - { name: oro_form.autocomplete.search_handler, alias: oro_enabled_localization, acl_resource: oro_locale_localization_view }

    oro_customer.logger.customer_user_login_attempt:
        class: Oro\Bundle\UserBundle\Security\UserLoginAttemptLogger
        public: true
        arguments:
            - '@doctrine'
            - '@oro_customer.provider.user_logging_info_provider'
            - '@translator'
            - '@logger'
            - Oro\Bundle\CustomerBundle\Entity\CustomerUserLoginAttempt
            - '%oro_customer_user.login_sources%'
        tags:
            - { name: monolog.logger, channel: security }

    oro_customer.event_listener.wsse_authentication:
        class: Oro\Bundle\CustomerBundle\EventListener\WsseAuthenticationListener
        arguments:
            - "@oro_customer.logger.customer_user_login_attempt"
        tags:
            - { name: kernel.event_listener, event: security.authentication.success, method: onAuthenticationSuccess }

    oro_customer.listener.file_listener:
        class: Oro\Bundle\CustomerBundle\EventListener\FileListener
        decorates: 'oro_attachment.listener.file_listener'
        parent: 'oro_attachment.listener.file_listener'

    oro_customer.entity_listener.send_changed_customer_address_type_to_message_queue:
        class: Oro\Bundle\CustomerBundle\EventListener\Entity\SendChangedAddressTypeToMessageQueueListener
        arguments:
            - '@oro_message_queue.message_producer'
            - '@security.token_storage'
            - '@oro_dataaudit.converter.entity_to_entity_change_array'
            - '@oro_dataaudit.audit_config_provider'
            - '@oro_dataaudit.provider.audit_message_body_provider'
            - '@oro_distribution.handler.application_status'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerAddress'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerAddressToAddressType'
        tags:
            - { name: doctrine.event_listener, event: onFlush }
            - { name: doctrine.event_listener, event: postFlush }

    oro_customer.entity_listener.send_changed_customer_user_address_type_to_message_queue:
        class: Oro\Bundle\CustomerBundle\EventListener\Entity\SendChangedAddressTypeToMessageQueueListener
        arguments:
            - '@oro_message_queue.message_producer'
            - '@security.token_storage'
            - '@oro_dataaudit.converter.entity_to_entity_change_array'
            - '@oro_dataaudit.audit_config_provider'
            - '@oro_dataaudit.provider.audit_message_body_provider'
            - '@oro_distribution.handler.application_status'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUserAddress'
            - 'Oro\Bundle\CustomerBundle\Entity\CustomerUserAddressToAddressType'
        tags:
            - { name: doctrine.event_listener, event: onFlush }
            - { name: doctrine.event_listener, event: postFlush }

    oro_customer.forced_password_reset.widget_provider.actions:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - oro_customer_user_force_password_reset_button
            - oro_customer_user_force_password_reset_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity, priority: 120 }

    oro_customer.create_subsidiary.widget_provider.actions:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - customer_create_subsidiary_button
            - customer_create_subsidiary_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity }

    oro_customer.customer_create_for_customer_group.widget_provider.actions:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - customer_create_for_customer_group_button
            - customer_create_for_customer_group_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity }

    oro_customer.customer_user.create_for_customer.widget_provider.actions:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - customer_user_create_for_customer_button
            - customer_user_create_for_customer_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity }

    oro_customer.owner.cache.warmer:
        class: Oro\Bundle\CustomerBundle\Cache\OwnerCacheWarmer
        arguments:
            - '@oro_customer.owner.tree_provider'
        tags:
            - { name: kernel.cache_warmer, priority: -250 }

    oro_customer.security.acl.visitor.cache.doctrine.cache_impl:
        public: false
        parent: oro.data.cache
        tags:
            - { name: 'cache.pool', namespace: 'oro_acl_visitor' }

    oro_customer.security.acl.visitor.cache:
        public: false
        class: Oro\Bundle\CustomerBundle\Acl\Cache\CustomerVisitorAclCache
        arguments:
            - '@oro_customer.security.acl.visitor.cache.doctrine.cache_impl'

    oro_customer.security.voter.customer_visitor_acl_voter.decorator:
        class: Oro\Bundle\CustomerBundle\Acl\Voter\CustomerVisitorAclVoterDecorator
        decorates: oro_security.acl.voter.basic_permissions
        decoration_priority: 250 #current decorator should be the last one
        arguments:
            - '@.inner'
            - '@oro_customer.security.acl.visitor.cache'
            - '@oro_website.request_website_provider'

    oro_customer.event_listener.website_update_guest_role_listener:
        class: Oro\Bundle\CustomerBundle\EventListener\WebsiteUpdateGuestRoleListener
        arguments:
            - '@oro_customer.security.acl.visitor.cache'
        tags:
            - { name: doctrine.orm.entity_listener, entity: Oro\Bundle\WebsiteBundle\Entity\Website, event: postUpdate }

    oro_customer.cache.page_request_provider:
        class: Oro\Bundle\CustomerBundle\Provider\CustomerPageRequestProvider
        parent: oro_platform.cache.provider.page_request_provider.abstract
        tags:
            - { name: warmup_page_request_provider }

    oro_customer.security.doctrine_acl_cache_listener:
        class: Oro\Bundle\CustomerBundle\Security\Listener\CustomerUserDoctrineAclCacheListener
        arguments:
            - '@oro_security.acl_query.cache_provider'
            - '@oro_customer.owner.tree_provider'
        tags:
            - { name: doctrine.event_listener, event: onFlush }

    oro_customer.acl_query.cache_user_info_provider_decorator:
        class: Oro\Bundle\CustomerBundle\Security\Cache\DoctrineAclCacheCustomerUserInfoProvider
        decorates: oro_security.acl_query.cache_user_info_provider
        arguments:
            - '@oro_security.token_accessor'
            - '@.inner'

    oro_customer.event_listener.anonymous_user_email_send:
        class: Oro\Bundle\CustomerBundle\EventListener\AnonymousUserEmailSendListener
        arguments:
            - '@security.token_storage'
            - '@oro_website.manager'
        tags:
            - { name: kernel.event_listener, event: 'oro_customer.customer_user_email_send_event', method: onCustomerUserEmailSend }
