#
# Module services
#
# Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
# See https://www.x-cart.com/license-agreement.html for license details.

services:
  _defaults:
    autowire: true
    autoconfigure: true

  XC\SplitShipment\Logic\ShipmentProviderFactory: ~
  XC\SplitShipment\Logic\ShipmentsCandidatesProviderFactory:
    arguments:
      $logger: '@xc.split.shipment.logger'

  XC\SplitShipment\Logic\ShipmentCandidates\ShipmentsCandidatesProvider:
    factory: ['@XC\SplitShipment\Logic\ShipmentsCandidatesProviderFactory', buildProvider]
    public: true

  XC\SplitShipment\Logic\Shipment\ShipmentProvider:
    factory: ['@XC\SplitShipment\Logic\ShipmentProviderFactory', buildProvider]
    public: true

  XC\SplitShipment\Logic\ShipmentCandidates\LocalShipmentsCandidatesProvider:
    tags:
      - {name: 'xc.split_shipment.shipment_candidate_provider', priority: 1000}

  XC\SplitShipment\Core\EventListener:
    tags:
      - {name: kernel.event_listener, event: xcart.service.view-list.collect-mutation, method: onCollectViewListMutations}

  XC\SplitShipment\EntityCallback\ShipmentCallback:
    tags:
      - {name: doctrine.orm.entity_listener, event: prePersist, entity: XC\SplitShipment\Model\Shipment}
      - {name: doctrine.orm.entity_listener, event: preUpdate, entity: XC\SplitShipment\Model\Shipment}

  XC\SplitShipment\EntityCallback\ShipmentItemCallback:
    tags:
      - {name: doctrine.orm.entity_listener, event: prePersist, entity: XC\SplitShipment\Model\ShipmentItem}
      - {name: doctrine.orm.entity_listener, event: preUpdate, entity: XC\SplitShipment\Model\ShipmentItem}

  split.shipment.xcart.repository.shipment:
    class: XLite\Model\Repo\ARepo
    factory: ['@doctrine.orm.default_entity_manager', getRepository]
    arguments:
      - XC\SplitShipment\Model\Shipment

  split.shipment.xcart.repository.order:
    class: XLite\Model\Repo\Order
    factory: ['@doctrine.orm.default_entity_manager', getRepository]
    arguments:
      - XLite\Model\Order

  XC\SplitShipment\Identifier\OrderShipmentIdentifier:
    public: true
    arguments:
      $orderRepo: '@split.shipment.xcart.repository.order'
      $shipmentRepo: '@split.shipment.xcart.repository.shipment'

  xc.split.shipment.logger:
    class: Psr\Log\LoggerInterface
    public: true
    factory: ['@XLite\Logger', getLogger]
    arguments:
      - 'XC-SplitShipment'
