<?php

namespace domain\Order\Order\Event;

use domain\Document\DeliveryNote\DeliveryNote;
use domain\Document\DeliveryNote\Event\DeliveryNoteCreateEvent;
use justcoded\yii2\eventlistener\observers\Observer;
use domain\Order\Order\OrderModule;

class DeliveryNoteObserver extends Observer
{
    public function events()
    {
        return [
            DeliveryNote::EVENT_CREATE => 'onDeliveryNoteCreate'
        ];
    }

    public function onDeliveryNoteCreate(DeliveryNoteCreateEvent $event)
    {
        $orderModule = OrderModule::getInstance();
        $orderModule->assignAllOrdersDeliveryNote($event->idOrders, $event->deliveryNote);
    }
}