Merge branch 'Issue_#37,_New_Namespaces' into 'master'

Added Controller Abstract for multiple parent classes of controller

See title

See merge request !15
This commit is contained in:
Abel Hoogeveen 2015-04-29 19:37:12 +02:00
commit 584148e16d
3 changed files with 81 additions and 2 deletions

View File

@ -1,9 +1,9 @@
<?php
namespace Controller;
use \FuzeWorks\Bus;
use \FuzeWorks\Controller;
class Standard extends Bus {
class Standard extends Controller {
public function __construct(&$core) {
parent::__construct($core);
}

View File

@ -0,0 +1,78 @@
<?php
namespace FuzeWorks;
/**
* Interface for a Module that gives abstract Controller types
* A Controller server must contain the methods from this interface in order to correctly serve Controllers
*/
interface ControllerServer {
public function giveController($type);
}
/**
* Abstract class Controller
*
* Abstract for a Controller data representation, loads the correct parent type
*/
abstract class Controller extends Bus{
/**
* The parent class holder object
* Requests get redirected to this class
* @access private
* @var Parent Object
*/
private $parentClass;
/**
* Constructs the class and Bus
* @access public
* @param Core Object, gets referenced
*/
public function __construct(&$core) {
parent::__construct($core);
}
/**
* Set the type of this Controller. Eg, use techfuze/databaseController and DatabaseController to get a SQL connected Controller
* @access protected
* @param String Module_name, the name of the module where the Controller can be found
* @param String Controller_type, Controller type to return
*/
protected function setType($module_name, $controller_type) {
$mod = $this->core->loadMod($module_name);
$this->parentClass = $mod->giveController($controller_type);
}
/**
* Retrieves a value from the controller class
* @access public
* @param Any key
* @return Any value from the controller class
*/
public function __get($name) {
return $this->parentClass->$name;
}
/**
* Sets a value in the controller class
* @access public
* @param Any key
* @param Any value
*/
public function __set($name, $value) {
$this->parentClass->$name = $value;
}
/**
* Calls a function in the controller class
* @access public
* @param String function_name
* @param Array values
* @return Function return
*/
public function __call($name, $params) {
return call_user_func_array(array($this->parentClass, $name), $params);
}
}

View File

@ -55,6 +55,7 @@ class Core {
require_once(FUZESYSPATH . "/class.abstract.event.php");
require_once(FUZESYSPATH . "/class.abstract.module.php");
require_once(FUZESYSPATH . "/class.abstract.model.php");
require_once(FUZESYSPATH . "/class.abstract.controller.php");
require_once(FUZESYSPATH . "/class.abstract.eventPriority.php");
// Load the core classes