Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

OrderObserver.php 687B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace domain\Payment\Event;
  3. use domain\Order\Order\Event\OrderDeleteEvent;
  4. use domain\Order\Order\Order;
  5. use domain\Payment\PaymentModule;
  6. use justcoded\yii2\eventlistener\observers\Observer;
  7. use domain\User\User\UserModule;
  8. class OrderObserver extends Observer
  9. {
  10. public function events()
  11. {
  12. return [
  13. Order::EVENT_DELETE => 'onOrderDelete'
  14. ];
  15. }
  16. public function onOrderDelete(OrderDeleteEvent $event)
  17. {
  18. $order = $event->order;
  19. $paymentManager = PaymentModule::getInstance();
  20. $userModule = UserModule::getInstance();
  21. $paymentManager->refundOrderCredit($order, $userModule->getCurrent());
  22. }
  23. }