My favorites | Sign in
Project Logo
                
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
40
41
42
43
44
45
46
<?php
/**
* SMTP_Server_API
*
* @author Jason Johnson <jason@php-smtp.org>
* @copyright Copyright (c) 2008, Jason Johnson
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @version 1.0
* @package php-smtp
*/

class SMTP_Server_API {
var $events = array();
var $hooks = array();

function register_event($event, $function) {
$this->events[$event][] = $function;
}

function register_hook($hook, $function) {
$this->hooks[$hook][] = $function;
}

function event() {
$args = func_get_args();
$event = array_shift($args);

for($i = 0; $i < count($this->events[$event]); $i++) {
call_user_func_array($this->events[$event][$i], $args);
}
}

function hook() {
$args = func_get_args();
$hook = array_shift($args);

for($i = 0; $i < count($this->hooks[$hook]); $i++) {
if(call_user_func_array($this->hooks[$hook][$i], $args) == false) {
return false;
}
}

return true;
}
}
?>
Show details Hide details

Change log

r24 by spligak on Apr 10, 2008   Diff
Added a basic API infrastructure and a
little more housecleaning
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 959 bytes, 46 lines
Hosted by Google Code