- Added an event manager. Also, fixed some more bugs within Block and Section tokens
This commit is contained in:
1 parent
58f73d914b
commit
08211282c2
14 files changed
+164
-18
No files matched your search
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Picea;
|
||||
|
||||
trait EventTrait
|
||||
{
|
||||
protected $_eventTraitMethod = "execute";
|
||||
|
||||
public array $_eventList = [];
|
||||
|
||||
protected array $_returnList = [];
|
||||
|
||||
public function eventRegister(object $event) : void
|
||||
{
|
||||
$this->_eventList[] = $event;
|
||||
}
|
||||
|
||||
public function eventFromType(string $type) : array
|
||||
{
|
||||
return array_filter($this->_eventList, fn($ev) => $ev instanceof $type);
|
||||
}
|
||||
|
||||
public function eventExecute(string $type, ...$arguments) : void
|
||||
{
|
||||
foreach($this->eventFromType($type) as $event) {
|
||||
$this->_returnList[$event::class][] = call_user_func_array([ $event, $this->_eventTraitMethod ], $arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user