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.

31 lines
837B

  1. <?php
  2. namespace domain\Product\Rotating\Event;
  3. use domain\Product\Rotating\Rotating;
  4. use domain\Product\Rotating\RotatingModule;
  5. use justcoded\yii2\eventlistener\observers\Observer;
  6. use yii\base\ErrorException;
  7. class RotatingObserver extends Observer
  8. {
  9. public function events(): array
  10. {
  11. return [
  12. RotatingSaveEvent::NAME => 'onRotatingSave'
  13. ];
  14. }
  15. /**
  16. * @throws ErrorException
  17. */
  18. public function onRotatingSave(RotatingSaveEvent $event)
  19. {
  20. $rotatingModule = RotatingModule::getInstance();
  21. $rotating = $event->rotating;
  22. // Obligé de recharger le Rotating
  23. $rotating = $rotatingModule->getRepository()->findOneRotatingById($rotating->getId());
  24. $rotatingModule->getManager()->initializeRotatingInDistributionsIncoming($rotating);
  25. }
  26. }