PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Events / EventDispatcher.php

EventDispatcher.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Events/EventDispatcher.php

59 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Events;
4
5 use FluentCart\App\Listeners\Activity;
6 use FluentCart\Framework\Support\ArrayableInterface;
7
8 abstract class EventDispatcher implements ArrayableInterface
9 {
10 protected array $listeners = [];
11 public string $hook = '';
12 public bool $autoFireHook = true;
13
14
15 public function dispatch()
16 {
17 $this->beforeDispatch();
18 $iterableListeners = $this->listeners;
19 $iterableListeners[] = Activity::class;
20
21 foreach ($iterableListeners as $listener) {
22 $listener::handle($this);
23 }
24
25 $this->afterDispatch();
26
27 if (!empty($this->hook) && $this->autoFireHook) {
28 do_action($this->hook, $this->toArray());
29 }
30 }
31
32 public function shouldCreateActivity(): bool
33 {
34 return true;
35 }
36
37 public function getEventInfoForActivity(): array
38 {
39 return [];
40 }
41
42
43 /**
44 * @return mixed
45 */
46 abstract public function getActivityEventModel();
47
48 public function beforeDispatch()
49 {
50
51 }
52
53 public function afterDispatch()
54 {
55
56 }
57
58 }
59