Beste helpers
ik ben sinds kort bezig om aan te leren OOP te gaan programmeren nu wil ik een abstracte classe maken voor mijn View alleen hij geeft aan dat hij niet geiniteerd is.
Verder heb ik hier weinig kaas van gegeten omdat ik pas net begin met OOP dus zou iemand mij kunnen uitleggen wat ik fout doe?
Alvast bedankt,
Slabbetje
ik ben sinds kort bezig om aan te leren OOP te gaan programmeren nu wil ik een abstracte classe maken voor mijn View alleen hij geeft aan dat hij niet geiniteerd is.
Verder heb ik hier weinig kaas van gegeten omdat ik pas net begin met OOP dus zou iemand mij kunnen uitleggen wat ik fout doe?
Alvast bedankt,
Slabbetje
PHP:
Class Main
{
public $Plugins = Array(); //Array for all the plugins
public $Debug = true; //Boolean if the debug mode is ON or OFF
public $noOutput = false; //Boolean if there comes a output ON or OFF
//Constructor this will load all the plugins etc.
public function __construct()
{
$this -> Plugins = Array();
$this -> loadClass( "errorHandler" , "./Engine/" , "Plugin");
$this -> loadClass( "requestHandler" , "./Engine/" , "Plugin" );
$this -> loadClass( "databaseHandler" , "./Engine/" , "Plugin" );
try
{
require("Pages/View.php");
$request_object = new View();
$request_object = requestHandler::request();
$view_className = $request_object;
$viewReflector = new ReflectionClass($view_className);
$scherm = $viewReflector->newInstanceArgs(array(
$this
, requestHandler::Request()
));
} catch (LogicException $error) {
}
}
//This is the function for loading the plugins
public function loadClass( $className, $classDir = "Pages", $classType = "Plugin")
{
if ( isset($this -> errorHandler) )
{
if ( file_exists( $classDir . $className . ".php" ) )
{
require( $classDir . $className . ".php" );
$this -> $className = new $className( $this );
$this -> errorHandler -> Error("[" . $classType . "] ". $className . " is succesfully loaded");
} else {
$this -> errorHandler -> Error("[" . $classType . "] Error loading " .$className. " Class");
}
} else {
require( $classDir . $className . ".php" );
$this -> $className = new $className( $this );
$this -> errorHandler -> Error("[" . $classType . "] ". $className . " is succesfully loaded");
}
}
public function __destruct()
{
$this-> errorHandler -> Error("[Global] Engine is succesfully loaded");
}
}
PHP:
Abstract Class requestHandler
{
public $PluginName = "requestHandler";
public $Engine;
private static $Request;
private static $Action;
public static function config()
{
//Spul returnen
static $run;
if (TRUE === $run)
{
return;
}
$run = TRUE;
$request_string = str_replace(URL_BASE, "", $_SERVER['REQUEST_URI']);
$request_array = explode("/", $request_string);
$request = array_filter($request_array);
if ( is_array($request) && 0 < count($request) && $request[0] != "index.php" )
{
self::$Request = array_shift($request);
} else {
self::$Request = 'Index';
}
self::$Action = $request;
}
public static function request()
{
self::config();
return self::$Request;
}
public static function get($i)
{
self::config();
return self::$Action[$i];
}
public static function getAll()
{
self::config();
return self::$Action;
}
}