yP
in package
It's a class that's used to dispatch events.
Table of Contents
- $instance : yP|null
- $listeners : array<string|int, mixed>
- __construct() : mixed
- It's looping through all the events in the `init()` function and dispatching them to the `yxorP()` function
- addListener() : void
- This function adds a listener to the listeners array
- loadActions() : void
- autoLoader() : void
- It's looping through all the files in the `$root` directory, and if the file is a directory, it's calling the `autoLoader()` function on it. If the file is an interface, it's requiring it. If the file is a class, it's requiring it.
- addSubscriber() : void
- It's checking if the `subscribe()` method exists in the `$subscriber` object, and if it does, it's calling it, and passing the `self::$instance` object to it
- dispatch() : void
- The function is checking if there are any listeners for the event, and if there are, it's looping through them and calling them.
- init() : void
- subscribe() : void
- It checks if the file exists in the plugin directory, if it does, it requires it, if it doesn't, it checks if the class exists in the yxorP namespace, if it does, it creates an instance of it
Properties
$instance
private
static yP|null
$instance
= null
$listeners
private
array<string|int, mixed>
$listeners
= []
Methods
__construct()
It's looping through all the events in the `init()` function and dispatching them to the `yxorP()` function
public
__construct(string $root[, array<string|int, mixed>|null $request = null ]) : mixed
Parameters
- $root : string
- $request : array<string|int, mixed>|null = null
Return values
mixed —addListener()
This function adds a listener to the listeners array
public
final addListener(string $event, object $callback) : void
Parameters
- $event : string
- $callback : object
Return values
void —The priority of the listener. Higher priority listeners are called before lower priority listeners.
loadActions()
public
final static loadActions() : void
Return values
void —A method that takes an array as a parameter and returns nothing.
autoLoader()
It's looping through all the files in the `$root` directory, and if the file is a directory, it's calling the `autoLoader()` function on it. If the file is an interface, it's requiring it. If the file is a class, it's requiring it.
protected
final static autoLoader(string $root) : void
Parameters
- $root : string
Return values
void —addSubscriber()
It's checking if the `subscribe()` method exists in the `$subscriber` object, and if it does, it's calling it, and passing the `self::$instance` object to it
private
addSubscriber(object $subscriber) : void
Parameters
- $subscriber : object
Return values
void —dispatch()
The function is checking if there are any listeners for the event, and if there are, it's looping through them and calling them.
private
dispatch(string $event_name) : void
Parameters
- $event_name : string
Return values
void —init()
private
init(array<string|int, mixed>|null $request) : void
Parameters
- $request : array<string|int, mixed>|null
Return values
void —A method that takes an array as a parameter and returns nothing.
subscribe()
It checks if the file exists in the plugin directory, if it does, it requires it, if it doesn't, it checks if the class exists in the yxorP namespace, if it does, it creates an instance of it
private
subscribe(string $root, string $action) : void
Parameters
- $root : string
- $action : string