-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.php
More file actions
90 lines (82 loc) · 2.12 KB
/
Controller.php
File metadata and controls
90 lines (82 loc) · 2.12 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace BlueSeed;
use BlueSeed\Request;
/**
*
* The controller to support interpretation of requests
* @author ivonascimento <ivo@o8o.com.br>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @package system
* @abstract
*/
use BlueSeed\Observer\ObserverCollection;
use BlueSeed\Observer\Observable;
use BlueSeed\Observer\Observer;
abstract class Controller implements Observable{
/**
*
* the observer Collection to ApplicationController
* @var ObserverCollection
*/
protected $observerCollection=Array();
/**
* The name of requested Controller
* @var String
* @access protected
*/
protected $controller;
/**
* the name of requested Action
* @var String
* @access protected
*/
protected $action;
/**
* The constructor set the needed variables to operate the action
* @param Request $R the request the Application Receive
* @access public
*/
public function __construct(Request $R){
$this->Request = $R;
$this->controller = $this->Request->getQuery(0);
$this->action = $this->Request->getQuery(1);
}
/**
* Retrieve the Request Object
* @return \BlueSeed\Request
*/
public function getRequest()
{
return $this->Request;
}
/**
* (non-PHPdoc)
* @see BlueSeed\Observer.Observable::attachObserver()
*/
public function attachObserver(Observer $o)
{
array_push($this->observerCollection, $o);
}
/**
* (non-PHPdoc)
* @see BlueSeed\Observer.Observable::detachObserver()
*/
public function detachObserver(Observer $o)
{
foreach ($this->observerCollection as $okey => $observer) {
if ($observer === $o)
unset($this->observerCollection[$okey]);
break;
}
}
/**
* (non-PHPdoc)
* @see BlueSeed\Observer.Observable::notifyObservers()
*/
public function notifyObservers()
{
foreach ($this->observerCollection as $observer) {
$observer->update ($this);
}
}
}