-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilterBuilder.php
39 lines (35 loc) · 967 Bytes
/
FilterBuilder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Themosis\Hook;
class FilterBuilder extends Hook
{
/**
* Run all filters registered with the hook.
*
* @param string $hook The filter hook name.
* @param mixed $args
*
* @return $this
*/
public function run($hook, $args = null)
{
if (is_array($args)) {
apply_filters_ref_array($hook, $args);
} else {
apply_filters($hook, $args);
}
return $this;
}
/**
* Add a filter event for the specified hook.
*
* @param string $name
* @param \Closure|string|array $callback
* @param int $priority
* @param int $accepted_args
*/
protected function addEventListener($name, $callback, $priority, $accepted_args)
{
$this->hooks[$name] = [$callback, $priority, $accepted_args];
add_filter($name, $callback, $priority, $accepted_args);
}
}