123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace refill;
- use Log;
- use refill\event\card_crash;
- class EventManager
- {
- private static $stInstance = null;
- public static function instance()
- {
- if (self::$stInstance == null) {
- self::$stInstance = new EventManager();
- }
- return self::$stInstance;
- }
- private $mStubs = [];
- public function load()
- {
- $cfgs = [
- 'open_crash' => true,
- 'cfgs_crash' => [
- 'channels' => [],
- 'succ_interval' => 900
- ]
- ];
- $open_crash = $cfgs['open_crash'] ?? false;
- if($open_crash) {
- $crash = new card_crash();
- $crash->load($cfgs['cfgs_crash'] ?? []);
- $this->mStubs[] = $crash;
- }
- }
- public function onBeforeSubmit(order $order)
- {
- foreach ($this->mStubs as $stub)
- {
- if($stub->onBeforeSubmit($order) === false) {
- return false;
- }
- }
- return true;
- }
- public function onSubmit(order $order)
- {
- foreach ($this->mStubs as $stub) {
- $stub->onSubmit($order);
- }
- }
- public function onBeforeCommit(order $order, $ch_name): bool
- {
- foreach ($this->mStubs as $stub)
- {
- if ($stub->onBeforeCommit($order, $ch_name) === false) {
- return false;
- }
- }
- return true;
- }
- public function onCommit(order $order, $ch_name)
- {
- foreach ($this->mStubs as $stub) {
- $stub->onCommit($order, $ch_name);
- }
- }
- public function onNeterror(order $order, $ch_name)
- {
- foreach ($this->mStubs as $stub) {
- $stub->onNeterror($order, $ch_name);
- }
- }
- public function onNotify($refill_info, $order_info, $success)
- {
- foreach ($this->mStubs as $stub) {
- $stub->onNotify($$refill_info, $order_info, $success);
- }
- }
- public function onComplete($refill_info, $order_info, $success)
- {
- foreach ($this->mStubs as $stub) {
- $stub->onComplete($$refill_info, $order_info, $success);
- }
- }
- }
|