StatusContainer.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2018/6/20
  6. * Time: 上午11:20
  7. */
  8. namespace app\common\modules\status;
  9. use app\common\modules\payType\remittance\models\status\RemittanceAuditStatus;
  10. use app\common\modules\payType\remittance\models\status\RemittanceStatus;
  11. use app\common\modules\process\events\AfterProcessStatusChangedEvent;
  12. use Illuminate\Container\Container;
  13. class StatusContainer extends Container
  14. {
  15. /**
  16. * StatusContainer constructor.
  17. */
  18. public function __construct()
  19. {
  20. $this->setBinds();
  21. }
  22. public function handle(AfterProcessStatusChangedEvent $event)
  23. {
  24. if ($this->bound($event->getProcess()->code)) {
  25. $this->make($event->getProcess()->code)->handle($event->getProcess());
  26. }
  27. }
  28. public function setBinds()
  29. {
  30. // collect(\app\common\modules\shop\ShopConfig::current()->get('status'))->each(function ($item,$key) {
  31. // $this->bind($key, function (StatusContainer $container) use ($item) {
  32. // return new $item();
  33. //
  34. // });
  35. // });
  36. collect(\app\common\modules\shop\ShopConfig::current()->get('shop-foundation.status'))->each(function ($item) {
  37. $this->bind($item['key'], function (StatusContainer $container) use ($item) {
  38. return new $item['class']();
  39. });
  40. });
  41. }
  42. }