services:
    oro_serialized_fields.migration.searilized_data.post_up.listener:
        class: Oro\Bundle\EntitySerializedFieldsBundle\EventListener\SerializedDataPostUpMigrationListener
        arguments:
            - "@oro_entity_extend.migration.entity_metadata_helper"
        tags:
            - { name: kernel.event_listener, event: oro_migration.post_up, method: onPostUp, priority: -95 }

    oro_serialized_fields.migration.extension.serialized_fields:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Migration\Extension\SerializedFieldsExtension
        arguments:
            - '@oro_entity_extend.migration.options_manager'
        tags:
            - { name: oro_migration.extension, extension_name: serialized_fields }

    oro_serialized_fields.migration.serialized_columns_holder_helper:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Migration\SerializedColumnsHolderHelper
        public: true
        arguments:
            - '@oro_entity_extend.migration.entity_metadata_helper'

    oro_serialized_fields.entity_field.extension:
        class: Oro\Bundle\EntitySerializedFieldsBundle\EntityExtend\SerializedEntityFieldExtension
        arguments:
            - '@oro_serialized_fields.normalizer.fields_compound_normalizer'
        tags:
            - { name: 'oro_entity_extend.entity_field_extension', priority: 100 }

    oro_serialized_fields.entity_config_dumper.extension:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Tools\DumperExtensions\SerializedEntityConfigDumperExtension
        arguments:
            - "@oro_entity_config.config_manager"
        tags:
            - { name: oro_entity_extend.entity_config_dumper_extension, priority: -256 }

    oro_serialized_fields.datagrid.column_options_guesser:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Grid\SerializedColumnOptionsGuesser
        arguments:
            - "@oro_entity_config.config_manager"
        tags:
            - { name: oro_datagrid.column_options_guesser }

    oro_serialized_fields.datagrid.serialized_fields_extension:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Grid\SerializedFieldsExtension
        parent: oro_entity_extend.datagrid.extension.dynamic_fields
        decorates: oro_entity_extend.datagrid.extension.dynamic_fields
        calls:
            - [setDbalTypes, ['%oro_serialized_fields.dbal_types%']]

    oro_serialized_fields.form.extension.field_extension:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Form\Extension\FieldTypeExtension
        arguments:
            - "@session"
            - ['fieldName', 'is_serialized', 'type']
        tags:
            - { name: form.type_extension, alias: oro_entity_extend_field_type, extended_type: Oro\Bundle\EntityExtendBundle\Form\Type\FieldType }

    oro_serialized_fields.validator.unique_extend_entity_field_validator:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Validator\Constraints\UniqueExtendEntityFieldValidator
        arguments:
            - '@oro_entity_extend.extend.field_name_validation_helper'
        tags:
            - { name: validator.constraint_validator }

    oro_serialized_fields.validator.extend_entity_serialized_data:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Validator\Constraints\ExtendEntitySerializedDataValidator
        arguments:
            - '@oro_entity_config.provider.extend'
            - '@oro_entity.helper.field_helper'
            - '@oro_entity_config.validator.field_config_constraints_factory'
        calls:
            -
                - addConstraints
                -
                    - integer
                    -
                        - Regex:
                              pattern: '/^[\d+]*$/'
                              message: "This value should contain only numbers."
            -
                - addConstraints
                -
                    - smallint
                    -
                        - Regex:
                              pattern: '/^[\d+]*$/'
                              message: "This value should contain only numbers."
            -
                - addConstraints
                -
                    - bigint
                    -
                        - Regex:
                              pattern: '/^[\d+]*$/'
                              message: "This value should contain only numbers."
            - [addConstraints, ['float', [{ Type: {type: 'numeric'} }]]]
            - [addConstraints, ['decimal', [{ Type: {type: 'numeric'} }]]]
            - [addConstraints, ['money', [{ Type: {type: 'numeric'} }]]]
            - [addConstraints, ['percent', [{ Type: {type: 'numeric'} }]]]
            - [addConstraints, ['date', [{Type: {type: 'DateTimeInterface', payload: {jsValidation: {type: Date}}}}]]]
            - [addConstraints, ['datetime', [{Type: {type: 'DateTimeInterface', payload: {jsValidation: {type: DateTime}}}}]]]
        tags:
            - { name: validator.constraint_validator, alias: oro_serialized_fields.validator.extend_entity_serialized_data }

    oro_serialized_fields.form.extension.config_extension:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Form\Extension\ConfigTypeExtension
        arguments:
            - ['fieldName', 'is_serialized', 'type']
        tags:
            - { name: form.type_extension, alias: oro_entity_config_type, extended_type: Oro\Bundle\EntityConfigBundle\Form\Type\ConfigType }

    oro_serialized_fields.form.type.is_serialized_field:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Form\Type\IsSerializedFieldType
        arguments:
            - '@oro_entity_config.provider.serialized_field_provider'
        tags:
            - { name: form.type, alias: oro_serialized_fields_is_serialized_type }

    oro_serialized_fields.listener.entity_config:
        class: Oro\Bundle\EntitySerializedFieldsBundle\EventListener\EntityConfigListener
        arguments:
            - '@oro_serialized_fields.entity_proxy_update_config_provider'
            - '@oro_entity_extend.entity_generator'
            - '@session'
        tags:
            - { name: kernel.event_listener, event: oro.entity_config.field.create, method: createField, priority: -255 }
            - { name: kernel.event_listener, event: oro.entity_config.pre_flush, method: preFlush, priority: -255 }
            - { name: kernel.event_listener, event: oro.entity_config.post_flush, method: postFlush }
            - { name: kernel.event_listener, event: oro.entity_config.pre_set_require_update, method: preSetRequireUpdate }

    oro_serialized_fields.entity_proxy_update_config_provider:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Provider\EntityProxyUpdateConfigProvider

    oro_serialized_fields.provider.deleted_attribute.decorator:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Provider\DeletedAttributeProviderDecorator
        decorates: oro_entity_config.provider.deleted_attribute
        arguments:
            - '@.inner'

    oro_serialized_fields.provider.deleted_serialized_attribute:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Provider\DeletedSerializedAttributeProvider
        arguments:
            - '@oro_entity_config.config_model_manager'
            - '@oro_serialized_fields.provider.serialized_attribute_value'

    oro_serialized_fields.provider.serialized_attribute_value:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Provider\SerializedAttributeValueProvider
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@property_accessor'

    oro_serialized_fields.event_listener.deleted_attribute_relation_serialized:
        class: Oro\Bundle\EntitySerializedFieldsBundle\EventListener\DeletedAttributeRelationListener
        arguments:
            - '@oro_message_queue.message_producer'
            - '@oro_serialized_fields.provider.deleted_serialized_attribute'
            - '@Doctrine\Inflector\Inflector'
        calls:
            - [setTopic, [!php/const Oro\Bundle\EntitySerializedFieldsBundle\Async\Topic\SerializedAttributeRemovedFromFamilyTopic::NAME]]
        tags:
            - { name: doctrine.event_listener, event: onFlush }
            - { name: doctrine.event_listener, event: postFlush }

    oro_serialized_fields.async.deleted_attribute_relation:
        class: Oro\Bundle\EntityConfigBundle\Async\DeletedAttributeRelationProcessor
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@logger'
            - '@oro_serialized_fields.provider.deleted_serialized_attribute'
        tags:
            - { name: oro_message_queue.client.message_processor, topicName: !php/const Oro\Bundle\EntitySerializedFieldsBundle\Async\Topic\SerializedAttributeRemovedFromFamilyTopic::NAME }

    oro_serialized_fields.normalizer.fields_compound_normalizer:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Normalizer\CompoundSerializedFieldsNormalizer
        public: true
        arguments:
            - !tagged_locator { tag: 'oro_serialized_fields.field_normalizer', index_by: 'field_type' }

    oro_serialized_fields.normalizer.datetime_normalizer:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Normalizer\DatetimeSerializedFieldNormalizer
        tags:
            - { name: 'oro_serialized_fields.field_normalizer', field_type: 'datetime' }
            - { name: 'oro_serialized_fields.field_normalizer', field_type: 'date' }

    oro_serialized_fields.normalizer.float_normalizer:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Normalizer\PercentSerializedFieldNormalizer
        tags:
            - { name: 'oro_serialized_fields.field_normalizer', field_type: 'percent' }

    oro_serialized_fields.provider.virtual_field_provider:
        class: Oro\Bundle\EntitySerializedFieldsBundle\Provider\SerializedVirtualFieldProvider
        arguments:
            - '%oro_serialized_fields.dbal_types%'
        tags:
            - { name: 'oro_entity.virtual_field_provider'}
