You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 line
812B

  1. <?php
  2. namespace domain\Document\DeliveryNote\Event;
  3. use domain\Document\DeliveryNote\DeliveryNote;
  4. use domain\Document\Document\DocumentModule;
  5. use justcoded\yii2\eventlistener\observers\Observer;
  6. use domain\Producer\Producer\ProducerModule;
  7. class DeliveryNoteObserver extends Observer
  8. {
  9. public function events()
  10. {
  11. return [
  12. DeliveryNote::EVENT_CREATE => 'onDeliveryNoteCreate'
  13. ];
  14. }
  15. public function onDeliveryNoteCreate(DeliveryNoteCreateEvent $event)
  16. {
  17. $producerModule = ProducerModule::getInstance();
  18. $documentModule = DocumentModule::getInstance();
  19. if($producerModule->getSolver()->getConfig('delivery_note_automatic_validation')) {
  20. $documentModule->getManager()->validateDocument($event->deliveryNote);
  21. }
  22. }
  23. }