In camelCase names are written without any punctuation, the start of each new word
being marked by a capital letter. The whole name starts with a capital letter as well.
Thus the name database provider becomes DatabaseProvider.
Loading history...
16
/**
17
* Registered callbacks for each hook
18
*
19
* @var array
20
*/
21
protected $hooks = array();
22
23
/**
24
* Constructor
25
*/
26
public function __construct() {
27
// pass
28
}
29
30
/**
31
* Register a callback for a hook
32
*
33
* @param string $hook Hook name
34
* @param callback $callback Function/method to call on event
35
* @param int $priority Priority number. <0 is executed earlier, >0 is executed later
36
*/
37
public function register($hook, $callback, $priority = 0) {
38
if (!isset($this->hooks[$hook])) {
39
$this->hooks[$hook] = array();
40
}
41
if (!isset($this->hooks[$hook][$priority])) {
42
$this->hooks[$hook][$priority] = array();
43
}
44
45
$this->hooks[$hook][$priority][] = $callback;
46
}
47
48
/**
49
* Dispatch a message
50
*
51
* @param string $hook Hook name
52
* @param array $parameters Parameters to pass to callbacks
53
* @return boolean Successfulness
54
*/
55
public function dispatch($hook, $parameters = array()) {
56
if (empty($this->hooks[$hook])) {
57
return false;
58
}
59
60
foreach ($this->hooks[$hook] as $priority => $hooked) {
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.