-
Notifications
You must be signed in to change notification settings - Fork 10
/
class.sphinxobservable.php
42 lines (33 loc) · 1.09 KB
/
class.sphinxobservable.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
40
41
42
<?php
class SphinxObservable implements SplSubject {
public $_Status = array(); //log of stuff that is happening
public $_Storage = array(); //storage of objects that are subscribed
public function __construct() {
//create subclasses
$this->_Storage = new SplObjectStorage();
}
public function Attach(SplObserver $Observer) {
$this->_Storage->attach($Observer);
}
public function Detach(SplObserver $Observer) {
$this->_Storage->detach($Observer);
}
public function GetStatus() {
return $this->_Status; //classic get operation
}
public function Notify() {
foreach ($this->_Storage as $Observer) {
$Observer->update($this);
}
}
public function Update($Level, $SettingsName, $Value = FALSE, $Msg = FALSE) {
$this->_Status [] = array(
'Name' => 'test',
'Priority' => $Level,
'SettingsName' => $SettingsName,
'Value' => $Value,
'Message' => $Msg
);
$this->Notify(); //let the subscribers know of this
}
}