| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,62 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace elanpl\L3; |
|
| 4 |
+ |
|
| 5 |
+abstract class ViewModel{
|
|
| 6 |
+ private $module; |
|
| 7 |
+ private $controller; |
|
| 8 |
+ private $action; |
|
| 9 |
+ public $_L3; |
|
| 10 |
+ |
|
| 11 |
+ public function __construct($arg) |
|
| 12 |
+ {
|
|
| 13 |
+ if($arg instanceof Applicstion){
|
|
| 14 |
+ $this->_L3 = $_L3; |
|
| 15 |
+ } |
|
| 16 |
+ else{
|
|
| 17 |
+ global $_L3; |
|
| 18 |
+ $this->_L3 = $_L3; |
|
| 19 |
+ } |
|
| 20 |
+ |
|
| 21 |
+ $match = $_L3->findControllerInCallStack(); |
|
| 22 |
+ |
|
| 23 |
+ $this->controller = $match['controller']; |
|
| 24 |
+ $this->module = $match['module']; |
|
| 25 |
+ $this->action = $match['action']; |
|
| 26 |
+ } |
|
| 27 |
+ |
|
| 28 |
+ public function getController(){
|
|
| 29 |
+ if(!isset($this->controller)){
|
|
| 30 |
+ throw new \Exception("Controller not found in ViewModel \"".get_class($this)."! Use parent::__construct() in the class constructor or setController method.");
|
|
| 31 |
+ } |
|
| 32 |
+ else |
|
| 33 |
+ return $this->controller; |
|
| 34 |
+ } |
|
| 35 |
+ |
|
| 36 |
+ public function getAction(){
|
|
| 37 |
+ if(!isset($this->action)){
|
|
| 38 |
+ throw new \Exception("Action not found in ViewModel \"".get_class($this)."! Use parent::___construct() in the class constructor or setAction method.");
|
|
| 39 |
+ } |
|
| 40 |
+ return $this->action; |
|
| 41 |
+ } |
|
| 42 |
+ |
|
| 43 |
+ public function getModule(){
|
|
| 44 |
+ return $this->module; |
|
| 45 |
+ } |
|
| 46 |
+ |
|
| 47 |
+ public function setController($controller){
|
|
| 48 |
+ return $this->controller = $controller; |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+ public function setAction($action){
|
|
| 52 |
+ return $this->action = $action; |
|
| 53 |
+ } |
|
| 54 |
+ |
|
| 55 |
+ public function setModule($module){
|
|
| 56 |
+ return $this->module = $module; |
|
| 57 |
+ } |
|
| 58 |
+ |
|
| 59 |
+ public function getDTO(){
|
|
| 60 |
+ //function to be overriden |
|
| 61 |
+ } |
|
| 62 |
+} |
|
| 0 | 63 |
\ No newline at end of file |