1 | <?php |
||
16 | class JoinPoint implements SplSubject |
||
17 | { |
||
18 | /** @var SplObjectStorage */ |
||
19 | protected $storage; |
||
20 | |||
21 | /** @var HttpGetRequest */ |
||
22 | protected $request; |
||
23 | |||
24 | /** @var HttpGetResponse */ |
||
25 | protected $response; |
||
26 | |||
27 | /** @var string */ |
||
28 | protected $name; |
||
29 | |||
30 | /** |
||
31 | * @param string $pointName |
||
32 | */ |
||
33 | 9 | public function __construct($pointName, HttpGetRequest $request) |
|
34 | { |
||
35 | 9 | $this->name = $pointName; |
|
36 | 9 | $this->detachAll(); |
|
37 | 9 | $this->request = $request; |
|
38 | 9 | } |
|
39 | |||
40 | 4 | public function attach(SplObserver $observer) |
|
44 | |||
45 | 1 | public function detach(SplObserver $observer) |
|
49 | |||
50 | 9 | public function detachAll() |
|
51 | { |
||
52 | 9 | $this->storage = new SplObjectStorage; |
|
53 | 9 | } |
|
54 | |||
55 | 3 | public function notify() |
|
56 | { |
||
57 | 3 | foreach ($this->storage as $observer) { |
|
58 | 3 | $observer->update($this); |
|
59 | 3 | } |
|
60 | 3 | } |
|
61 | |||
62 | 7 | final public function refRequest() |
|
66 | |||
67 | 1 | public function setRequest(HttpGetRequest $req) |
|
68 | { |
||
69 | 1 | $this->request = $req; |
|
70 | 1 | } |
|
71 | |||
72 | final public function refResponse() |
||
73 | { |
||
74 | return $this->response; |
||
75 | } |
||
76 | |||
77 | public function setResponse(HttpGetResponse $res) |
||
78 | { |
||
79 | $this->response = $res; |
||
80 | } |
||
81 | |||
82 | 6 | public function __toString() |
|
86 | } |
||
87 |