init
This commit is contained in:
38
mysyde/common/traits/hookableTrait.php
Normal file
38
mysyde/common/traits/hookableTrait.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace DynCom\mysyde\common\traits;
|
||||
|
||||
use DynCom\mysyde\common\classes\Hook;
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Bauer
|
||||
* Date: 15.07.2015
|
||||
* Time: 11:20
|
||||
*/
|
||||
trait hookableTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $eventName
|
||||
* @param $data
|
||||
*/
|
||||
protected function updateHooks($eventName, $data)
|
||||
{
|
||||
$parents = class_parents($this);
|
||||
$interfaces = class_implements($this);
|
||||
$className = get_class($this);
|
||||
$notificationTargets = [$className];
|
||||
$namespace = '';
|
||||
foreach ($parents as $parent) {
|
||||
$notificationTargets[] = $parent;
|
||||
}
|
||||
foreach ($interfaces as $interface) {
|
||||
$notificationTargets[] = $interface;
|
||||
}
|
||||
foreach ($notificationTargets as $target) {
|
||||
Hook::update($eventName, $data, $target);
|
||||
}
|
||||
Hook::update($eventName, $data);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user