imports:
  - { resource: "services/forms.yml" }
  - { resource: "services/installer.yml" }
  - { resource: "services/commands.yml" }
  - { resource: "services/import_rules.yml" }

services:
    Instride\Bundle\DataDefinitionsBundle\Event\EventDispatcher:
      arguments:
        - '@event_dispatcher'

    Instride\Bundle\DataDefinitionsBundle\Service\FieldSelection:
      public: true

    Instride\Bundle\DataDefinitionsBundle\Context\ContextFactoryInterface: '@Instride\Bundle\DataDefinitionsBundle\Context\ContextFactory'
    Instride\Bundle\DataDefinitionsBundle\Context\ContextFactory: ~

    Instride\Bundle\DataDefinitionsBundle\Importer\ImporterInterface: '@Instride\Bundle\DataDefinitionsBundle\Importer\Importer'
    Instride\Bundle\DataDefinitionsBundle\Importer\Importer:
      arguments:
        - '@data_definitions.registry.provider'
        - '@data_definitions.registry.filter'
        - '@data_definitions.registry.runner'
        - '@data_definitions.registry.interpreter'
        - '@data_definitions.registry.setter'
        - '@data_definitions.registry.cleaner'
        - '@data_definitions.registry.loader'
        - '@data_definitions.registry.persister'
        - '@Instride\Bundle\DataDefinitionsBundle\Event\EventDispatcher'
        - '@Instride\Bundle\DataDefinitionsBundle\Context\ContextFactoryInterface'
        - '@logger'
        - '@pimcore.model.factory'
        - '@coreshop.expression_language'
        - '@messenger.default_bus'
      tags:
        - { name: monolog.logger, channel: import_definition }
        - { name: 'kernel.event_listener', event: 'data_definitions.stop', method: 'stop' }

    Instride\Bundle\DataDefinitionsBundle\Exporter\ExporterInterface: '@Instride\Bundle\DataDefinitionsBundle\Exporter\Exporter'
    Instride\Bundle\DataDefinitionsBundle\Exporter\Exporter:
      arguments:
        - '@data_definitions.registry.fetcher'
        - '@data_definitions.registry.export_runner'
        - '@data_definitions.registry.interpreter'
        - '@data_definitions.registry.getter'
        - '@data_definitions.registry.export_provider'
        - '@Instride\Bundle\DataDefinitionsBundle\Context\ContextFactoryInterface'
        - '@event_dispatcher'
        - '@logger'
      tags:
        - { name: monolog.logger, channel: export_definition }
        - { name: 'kernel.event_listener', event: 'data_definitions.stop', method: 'stop' }

    ### Registries
    data_definitions.registry.provider:
      class: CoreShop\Component\Registry\ServiceRegistry
      public: true
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Provider\ImportProviderInterface
        - 'Import Definition Providers'

    data_definitions.form.registry.provider:
      class: CoreShop\Bundle\ResourceBundle\Form\Registry\FormTypeRegistry

    data_definitions.registry.export_provider:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Provider\ExportProviderInterface
        - 'Import Definition Export Providers'

    data_definitions.form.registry.export_provider:
      class: CoreShop\Bundle\ResourceBundle\Form\Registry\FormTypeRegistry

    data_definitions.registry.loader:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Loader\LoaderInterface
        - 'Import Definition Loaders'

    data_definitions.registry.cleaner:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Cleaner\CleanerInterface
        - 'Import Definition Cleaners'

    data_definitions.registry.filter:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Filter\FilterInterface
        - 'Import Definition Filters'

    data_definitions.registry.interpreter:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Interpreter\InterpreterInterface
        - 'Import Definition Interpreters'

    data_definitions.form.registry.interpreter:
      class: CoreShop\Bundle\ResourceBundle\Form\Registry\FormTypeRegistry

    data_definitions.registry.setter:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Setter\SetterInterface
        - 'Import Definition Setters'

    data_definitions.form.registry.setter:
      class: CoreShop\Bundle\ResourceBundle\Form\Registry\FormTypeRegistry

    data_definitions.registry.getter:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Getter\GetterInterface
        - 'Import Definition Getters'

    data_definitions.form.registry.getter:
      class: CoreShop\Bundle\ResourceBundle\Form\Registry\FormTypeRegistry

    data_definitions.registry.fetcher:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Fetcher\FetcherInterface
        - 'Import Definition Fetchers'

    data_definitions.form.registry.fetcher:
      class: CoreShop\Bundle\ResourceBundle\Form\Registry\FormTypeRegistry

    data_definitions.registry.runner:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Runner\RunnerInterface
        - 'Import Definition Runners'

    data_definitions.registry.export_runner:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Runner\ExportRunnerInterface
        - 'Export Definition Runners'

    data_definitions.registry.persister:
      class: CoreShop\Component\Registry\ServiceRegistry
      arguments:
        - Instride\Bundle\DataDefinitionsBundle\Persister\PersisterInterface
        - 'Import Definition Persisters'

    ### CLEANER
    Instride\Bundle\DataDefinitionsBundle\Cleaner\Deleter:
      tags:
        - { name: data_definitions.cleaner, type: deleter }

    Instride\Bundle\DataDefinitionsBundle\Cleaner\None:
      tags:
        - { name: data_definitions.cleaner, type: none }

    Instride\Bundle\DataDefinitionsBundle\Cleaner\ReferenceCleaner:
      tags:
        - { name: data_definitions.cleaner, type: reference_cleaner }

    Instride\Bundle\DataDefinitionsBundle\Cleaner\Unpublisher:
      tags:
        - { name: data_definitions.cleaner, type: unpublisher }

    ### INTERPRETER
    Instride\Bundle\DataDefinitionsBundle\Interpreter\AssetsUrlInterpreter:
      arguments:
        - '@Psr\Http\Client\ClientInterface'
        - '@Psr\Http\Message\RequestFactoryInterface'
      tags:
        - { name: data_definitions.interpreter, type: assets_url, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\AssetsUrlInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\AssetUrlInterpreter:
      arguments:
        - '@Psr\Http\Client\ClientInterface'
        - '@Psr\Http\Message\RequestFactoryInterface'
      tags:
        - { name: data_definitions.interpreter, type: asset_url, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\AssetUrlInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\MetadataInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: metadata, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\MetadataInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\AssetByPathInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: asset_by_path, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\AssetByPathInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\CarbonInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: carbon, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\CarbonInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\CheckboxInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: checkbox, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\DefaultValueInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: default_value, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\DefaultValueInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\SpecificObjectInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: specific_object, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\SpecificObjectInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\HrefInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: href, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\HrefInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\MultiHrefInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: multi_href, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\MultiHrefInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\QuantityValueInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: quantity_value, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\QuantityValueInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\NestedInterpreter:
      arguments:
        - '@data_definitions.registry.interpreter'
        - '@Instride\Bundle\DataDefinitionsBundle\Context\ContextFactoryInterface'
      tags:
        - { name: data_definitions.interpreter, type: nested, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\NestedInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\ExpressionInterpreter:
      arguments:
        - '@coreshop.expression_language'
        - '@service_container'
      tags:
        - { name: data_definitions.interpreter, type: expression, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\ExpressionInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\ObjectResolverInterpreter:
      arguments:
        - '@service_container'
      tags:
        - { name: data_definitions.interpreter, type: object_resolver, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\ObjectResolverType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\DefinitionInterpreter:
      arguments:
        - '@data_definitions.repository.import_definition'
        - '@Instride\Bundle\DataDefinitionsBundle\Importer\ImporterInterface'
      tags:
        - { name: data_definitions.interpreter, type: definition, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\DefinitionType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\ConditionalInterpreter:
      arguments:
        - '@data_definitions.registry.interpreter'
        - '@coreshop.expression_language'
        - '@service_container'
        - '@Instride\Bundle\DataDefinitionsBundle\Context\ContextFactoryInterface'
      tags:
        - { name: data_definitions.interpreter, type: conditional, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\ConditionalInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\MappingInterpreter:
      arguments:
        - '@service_container'
      tags:
        - { name: data_definitions.interpreter, type: mapping, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\MappingInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\IteratorInterpreter:
      arguments:
        - '@data_definitions.registry.interpreter'
        - '@Instride\Bundle\DataDefinitionsBundle\Context\ContextFactoryInterface'
      tags:
        - { name: data_definitions.interpreter, type: iterator, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\IteratorInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\TwigInterpreter:
      arguments:
        - '@twig'
      tags:
        - { name: data_definitions.interpreter, type: twig, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\TwigInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\DoNotSetOnEmptyInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: donotsetonempty, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\TypeCastingInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: type_casting, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Interpreter\TypeCastingInterpreterType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\LinkInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: link, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    Instride\Bundle\DataDefinitionsBundle\Interpreter\ExternalImageInterpreter:
      tags:
        - { name: data_definitions.interpreter, type: external_image, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    ### PROVIDER
    Instride\Bundle\DataDefinitionsBundle\Provider\CsvProvider:
      arguments:
        - '@Instride\Bundle\DataDefinitionsBundle\Service\StorageLocator'
        - '@Pimcore\Helper\LongRunningHelper'
      tags:
        - { name: data_definitions.import_provider, type: csv, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\ImportProvider\CsvProviderType }
        - { name: data_definitions.export_provider, type: csv, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\ExportProvider\CsvProviderType }

    Instride\Bundle\DataDefinitionsBundle\Provider\ExcelProvider:
      arguments:
        - '@Instride\Bundle\DataDefinitionsBundle\Service\StorageLocator'
        - '@Pimcore\Helper\LongRunningHelper'
      tags:
        - { name: data_definitions.import_provider, type: excel, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\ImportProvider\ExcelProviderType }
        - { name: data_definitions.export_provider, type: excel, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    Instride\Bundle\DataDefinitionsBundle\Provider\JsonProvider:
      arguments:
        - '@Instride\Bundle\DataDefinitionsBundle\Service\StorageLocator'
        - '@Pimcore\Helper\LongRunningHelper'
      tags:
        - { name: data_definitions.import_provider, type: json, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\ImportProvider\JsonProviderType }
        - { name: data_definitions.export_provider, type: json, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    Instride\Bundle\DataDefinitionsBundle\Provider\ExternalSqlProvider:
      tags:
        - { name: data_definitions.import_provider, type: external_sql, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\ImportProvider\ExternalSqlProviderType }

    Instride\Bundle\DataDefinitionsBundle\Provider\SqlProvider:
      arguments:
        - '@doctrine.dbal.default_connection'
      tags:
        - { name: data_definitions.import_provider, type: sql, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\ImportProvider\SqlProviderType }

    Instride\Bundle\DataDefinitionsBundle\Provider\XmlProvider:
      arguments:
        - '@Instride\Bundle\DataDefinitionsBundle\Service\StorageLocator'
        - '@Pimcore\Helper\LongRunningHelper'
      tags:
        - { name: data_definitions.import_provider, type: xml, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\ImportProvider\XmlProviderType }
        - { name: data_definitions.export_provider, type: xml, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\ExportProvider\XmlProviderType }

    Instride\Bundle\DataDefinitionsBundle\Provider\RawProvider:
      tags:
        - { name: data_definitions.import_provider, type: raw, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\ImportProvider\RawProviderType }

    ### SETTER AND GETTER
    Instride\Bundle\DataDefinitionsBundle\Setter\ClassificationStoreSetter:
      tags:
        - { name: data_definitions.setter, type: classificationstore, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Setter\ClassificationStoreSetterType }
        - { name: data_definitions.getter, type: classificationstore, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Setter\ClassificationStoreSetterType }

    Instride\Bundle\DataDefinitionsBundle\Setter\ClassificationStoreFieldGetter:
      tags:
        - { name: data_definitions.getter, type: classificationstore_field, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    Instride\Bundle\DataDefinitionsBundle\Setter\FieldCollectionSetter:
      tags:
        - { name: data_definitions.setter, type: fieldcollection, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Setter\FieldCollectionSetterType }
        - { name: data_definitions.getter, type: fieldcollection, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Setter\FieldCollectionSetterType }

    Instride\Bundle\DataDefinitionsBundle\Setter\KeySetter:
      tags:
        - { name: data_definitions.setter, type: key, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    Instride\Bundle\DataDefinitionsBundle\Setter\LocalizedfieldSetter:
      tags:
        - { name: data_definitions.setter, type: localizedfield, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Setter\LocalizedFieldSetterType }
        - { name: data_definitions.getter, type: localizedfield, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Setter\LocalizedFieldSetterType }

    Instride\Bundle\DataDefinitionsBundle\Setter\ObjectbrickSetter:
      tags:
        - { name: data_definitions.setter, type: objectbrick, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Setter\ObjectBrickSetterType }
        - { name: data_definitions.getter, type: objectbrick, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Setter\ObjectBrickSetterType }

    Instride\Bundle\DataDefinitionsBundle\Setter\ObjectTypeSetter:
      tags:
        - { name: data_definitions.setter, type: object_type, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    Instride\Bundle\DataDefinitionsBundle\Setter\RelationSetter:
      tags:
        - { name: data_definitions.setter, type: relation, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\NoConfigurationType }

    Instride\Bundle\DataDefinitionsBundle\EventListener\ObjectDeleteListener:
      tags:
        - { name: kernel.event_listener, event: pimcore.dataobject.postDelete, method: onDataObjectDelete }

    Instride\Bundle\DataDefinitionsBundle\Fetcher\ObjectsFetcher:
      tags:
        - { name: data_definitions.fetcher, type: objects, form-type: Instride\Bundle\DataDefinitionsBundle\Form\Type\Fetcher\ObjectsFetcherType }

    ### LOADER
    Instride\Bundle\DataDefinitionsBundle\Loader\PrimaryKeyLoader:
      tags:
        - { name: data_definitions.loader, type: primary_key }

    ### PERSISTER
    Instride\Bundle\DataDefinitionsBundle\Persister\Persister:
      tags:
        - { name: data_definitions.persister, type: persister }

    Instride\Bundle\DataDefinitionsBundle\Service\StorageLocator:
      arguments:
        $locator: !tagged_locator { tag: flysystem.storage }

    Instride\Bundle\DataDefinitionsBundle\EventListener\PimcoreSettingsListener:
      tags:
        - { name: kernel.event_listener, event: pimcore.admin.indexAction.settings, method: indexSettings }

    Instride\Bundle\DataDefinitionsBundle\EventListener\WriteableListener:
      tags:
        - { name: kernel.event_subscriber }

    Instride\Bundle\DataDefinitionsBundle\Messenger\ImportRowMessageHandler:
      arguments:
        - '@Instride\Bundle\DataDefinitionsBundle\Importer\ImporterInterface'
      tags:
        - { name: messenger.message_handler }
