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.

27 lines
734B

  1. <?php
  2. namespace domain\Product\Rotating\Event;
  3. use domain\Distribution\Distribution\Distribution;
  4. use domain\Distribution\Distribution\Event\DistributionActiveEvent;
  5. use domain\Product\Rotating\RotatingModule;
  6. use justcoded\yii2\eventlistener\observers\Observer;
  7. use yii\base\ErrorException;
  8. class DistributionObserver extends Observer
  9. {
  10. public function events()
  11. {
  12. return [
  13. Distribution::EVENT_ACTIVE => 'onDistributionActive'
  14. ];
  15. }
  16. /**
  17. * @throws ErrorException
  18. */
  19. public static function onDistributionActive(DistributionActiveEvent $event): void
  20. {
  21. RotatingModule::getInstance()->getManager()->initializeAllRotatingsInDistribution($event->distribution);
  22. }
  23. }