parameters:
    oro_security.entity.owners:
        organization: 'Oro\Bundle\OrganizationBundle\Entity\Organization'
        business_unit: 'Oro\Bundle\OrganizationBundle\Entity\BusinessUnit'
        user: 'Oro\Bundle\UserBundle\Entity\User'

services:
    oro_security.owner.entity_owner_accessor:
        class: Oro\Bundle\SecurityBundle\Owner\EntityOwnerAccessor
        arguments:
            - '@oro_security.owner.metadata_provider.chain'
            - '@Doctrine\Inflector\Inflector'

    oro_security.owner.entity_owner_accessor.link:
        tags:
            - { name: oro_service_link, service: oro_security.owner.entity_owner_accessor }

    oro_security.owner.metadata_provider.chain:
        class: Oro\Bundle\SecurityBundle\Owner\Metadata\ChainOwnershipMetadataProvider
        public: true
        calls:
            - [setDefaultProvider, ['@oro_security.owner.ownership_metadata_provider']]

    oro_security.owner.ownership_metadata_provider:
        class: Oro\Bundle\SecurityBundle\Owner\Metadata\OwnershipMetadataProvider
        arguments:
            - '%oro_security.entity.owners%'
            - '@oro_entity_config.config_manager'
            - '@oro_entity.orm.entity_class_resolver'
            - '@oro_security.token_accessor'
            - '@oro_security.owner.ownership_metadata_provider.cache'
        tags:
            - { name: oro_security.owner.metadata_provider, alias: default }

    oro_security.owner.ownership_metadata_provider.link:
        tags:
            - { name: oro_service_link, service: oro_security.owner.ownership_metadata_provider }

    oro_security.owner.ownership_metadata_provider.cache:
        parent: oro.data.cache
        public: false
        tags:
            - { name: 'cache.pool', namespace: 'oro_acl_entity_ownership' }

    oro_security.owner.ownership_config_listener:
        class: Oro\Bundle\SecurityBundle\EventListener\OwnershipConfigListener
        arguments:
            - '@oro_security.owner.metadata_provider.chain'
        tags:
            - { name: kernel.event_listener, event: oro.entity_config.pre_flush, method: preFlush }

    oro_security.owner.ownership_metadata_provider.cache.warmer:
        class: Oro\Bundle\SecurityBundle\Cache\OwnershipMetadataCacheWarmer
        public: false
        arguments:
            - '@oro_security.owner.metadata_provider.chain'
        tags:
            - { name: kernel.cache_warmer }

    oro_security.owner.ownership_decision_maker.chain:
        class: Oro\Bundle\SecurityBundle\Owner\ChainEntityOwnershipDecisionMaker

    oro_security.owner.ownership_query_helper:
        class: Oro\Bundle\SecurityBundle\Owner\OwnershipQueryHelper
        public: false
        arguments:
            - '@oro_security.owner.metadata_provider.chain'
            - '@oro_entity.orm.entity_class_resolver'
