api_platform:
  resource_class_directories:
    - '%kernel.project_dir%/var/run/classes/CDev/FileAttachments/Model'

dto_generator:
  entities:
    api:
      XCart\API\Entity\Storefront\Product\Detailed:
        fields:
          attachments:
            type: XCart\API\Entity\Storefront\FileAttachment[]
    logic:
      XCart\Logic\Entity\Storefront\Product:
        fields:
          attachments:
            type: XCart\Logic\Entity\Storefront\FileAttachment[]
    dto:
      XCart\API\Entity\Storefront\FileAttachment:
        fields:
          title:
            type: string
          description:
            type: string
          url:
            type: string
      XCart\Logic\Entity\Storefront\FileAttachment:
        fields:
          title:
            type: string
          description:
            type: string
          url:
            type: string

services:
  _defaults:
    autowire: true
    autoconfigure: true
    public: true

  # /product/{product_id}/attachments
  CDev\FileAttachments\API\Endpoint\ProductAttachment\Transformer\OutputTransformerInterface: '@CDev\FileAttachments\API\Endpoint\ProductAttachment\Transformer\OutputTransformer'
  CDev\FileAttachments\API\Endpoint\ProductAttachment\Transformer\OutputTransformer: ~
  CDev\FileAttachments\API\Endpoint\ProductAttachment\Transformer\InputTransformerInterface: '@CDev\FileAttachments\API\Endpoint\ProductAttachment\Transformer\InputTransformer'
  CDev\FileAttachments\API\Endpoint\ProductAttachment\Transformer\InputTransformer: ~

  CDev\FileAttachments\API\Endpoint\ProductAttachment\SubIriConverter\SubIriConverter:
    tags: [!php/const XCart\Framework\ApiPlatform\Core\Bridge\Symfony\Routing\SubIriConverter\SubIriFromItemConverterInterface::SUB_IRI_FROM_ITEM_CONVERTER_TAG]

  CDev\FileAttachments\API\Endpoint\ProductAttachment\DataProvider\CollectionDataProvider:
    arguments:
      $inner: '@api_platform.doctrine.orm.default.collection_data_provider'
      $repository: '@xcart.repository.product'

  CDev\FileAttachments\API\Endpoint\ProductAttachment\DataProvider\ItemDataProvider:
    arguments:
      $inner: '@api_platform.doctrine.orm.default.item_data_provider'
      $repository: '@xcart.repository.product'

  xcart.api.cdev.file_attachments.product_attachment.controller:
    class: CDev\FileAttachments\Controller\API\ProductAttachment\Post
    arguments:
      $repository: '@xcart.repository.product'

  CDev\FileAttachments\API\OpenApiTagsRepositoryDecorator:
    decorates: XLite\API\OpenApiTagsRepository

  xcart.api.cdev.file_attachments.product_attachment.sub_extension:
    class: CDev\FileAttachments\API\Endpoint\ProductAttachment\SubExtension\SubExtension
    tags: [!php/const XLite\API\Extension\CollectionSubExtension\CollectionSubExtensionInterface::COLLECTION_SUB_EXTENSION_TAG, !php/const XLite\API\Extension\ItemSubExtension\ItemSubExtensionInterface::ITEM_SUB_EXTENSION_TAG]

  xcart.logic.storefront.product.get_one_by_id.action.decorator.file_attachments:
    class: CDev\FileAttachments\Logic\Action\Storefront\Product\GetOne\ActionDecorator
    decorates: xcart.logic.storefront.product.get_one_by_id.action
    decoration_priority: 40
    arguments:
      $inner: '@.inner'
      $queryBuilderAssembler: '@xcart.logic.storefront.product.get_one_by_id.assembler.query_builder'

  xcart.logic.storefront.product.get_one_by_clean_url.action.decorator.file_attachments:
    class: CDev\FileAttachments\Logic\Action\Storefront\Product\GetOne\ActionDecorator
    decorates: xcart.logic.storefront.product.get_one_by_clean_url.action
    decoration_priority: 40
    arguments:
      $inner: '@.inner'
      $queryBuilderAssembler: '@xcart.logic.storefront.product.get_one_by_clean_url.assembler.query_builder'
