<?php

namespace common\logic\Order\Order\Event;

use common\logic\Document\DeliveryNote\Event\DeliveryNoteCreateEvent;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Order\Order\Module\OrderModule;
use justcoded\yii2\eventlistener\observers\Observer;

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);
    }
}