Skip to content

Commit

Permalink
revert trait
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Sep 21, 2024
1 parent 87b5995 commit d72930a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/Core/Events/DispatchesEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
trait DispatchesEvents
{
private static string $event_context = '';

/**
* dispatches an event with context
Expand Down Expand Up @@ -41,7 +42,7 @@ public static function dispatch_event(string $hook, mixed $available_params = []
*/
public static function dispatch_filter(string $hook, mixed $payload, mixed $available_params = [], string|int $function = null): mixed
{
return EventDispatcher::dispatch_filter($hook, $payload, $available_params, DispatchesEvents::get_event_context($function));
return EventDispatcher::dispatch_filter($hook, $payload, $available_params, static::get_event_context($function));
}

/**
Expand All @@ -52,16 +53,17 @@ public static function dispatch_filter(string $hook, mixed $payload, mixed $avai
* @param $function
* @return string
*/
public static function get_event_context($function): string
protected static function get_event_context($function): string
{

$event_context = DispatchesEvents::set_class_context();
if (empty(self::$event_context)) {
self::$event_context = static::set_class_context();
}

$function = !empty($function) && is_string($function) && !is_numeric($function)
? $function
: DispatchesEvents::get_function_context(is_numeric($function) ? (int) $function : null);
: static::get_function_context(is_numeric($function) ? (int) $function : null);

return $event_context . '.' . $function;
return self::$event_context . '.' . $function;
}

/**
Expand All @@ -72,7 +74,7 @@ public static function get_event_context($function): string
*
* @return string
*/
public static function set_class_context(): string
private static function set_class_context(): string
{
return str_replace('\\', '.', strtolower(get_called_class()));
}
Expand All @@ -87,7 +89,7 @@ public static function set_class_context(): string
* @param ?int $functionInt
* @return string
*/
public static function get_function_context(?int $functionInt = null): string
private static function get_function_context(?int $functionInt = null): string
{
$tracePointer = is_int($functionInt) ? $functionInt : 3;

Expand Down

0 comments on commit d72930a

Please sign in to comment.