implemented testaction in MVCController

This commit is contained in:
Andreas 2019-09-17 15:43:01 +02:00
parent 7eb0c18615
commit ecb21237f6
2 changed files with 21 additions and 3 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
class MVCController{ class MVCController{
private $model; private $model;
private $testaction;
private $viewmodel; private $viewmodel;
private $view; private $view;
private $viewOverridden = false; private $viewOverridden = false;
@ -28,7 +29,14 @@ class MVCController{
} }
else{ else{
$this->model = "./model/actions/model_empty.php"; $this->model = "./model/actions/model_empty.php";
} }
if(isset($_POST['testaction'])){
$this->testaction = "./model/testactions/model_".$_POST['testaction'].".php";
}
} }
static function getMVCController():MVCController static function getMVCController():MVCController
{ {
@ -51,7 +59,17 @@ class MVCController{
else{ else{
//debug message //debug message
echo("caught call on non-existant model file."); echo("caught call on non-existant model file.");
} }
//TESTACTION LAYER
//check if testaction is valid
if(file_exists($this->testaction)){
//execute testaction
include_once($this->testaction);
}
} }
function executeViewmodel():void function executeViewmodel():void

View File

@ -10,7 +10,7 @@ require_once('./controller/UserSession.php');
session_start(); session_start();
$mvcController = new MVCController(); $mvcController = new MVCController();
$mvcController->executeModel(); $mvcController->executeModel();
if(!isset($_POST['admin'])){ if(!isset($_POST['testaction'])){
include_once("./view/content_pagetemplate.php"); include_once("./view/content_pagetemplate.php");
} }
?> ?>