Merge branch 'Issue_#37,_New_Namespaces' into 'master'
Issue #34, new namespaces And a lot more! See commit log for detailed changes. Fixes #34, #31, parts of #12 and a lot of bugfixes! See merge request !13
This commit is contained in:
commit
f8b98f4c13
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Controller;
|
||||
use \FuzeWorks\Bus;
|
||||
|
||||
class Standard extends Bus {
|
||||
public function __construct(&$core) {
|
||||
parent::__construct($core);
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Model;
|
||||
use \FuzeWorks\Model;
|
||||
|
||||
class Example extends Model{
|
||||
|
||||
public function __construct(&$core){
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use \FuzeWorks\Event;
|
||||
|
||||
class ControllerLoadEvent extends Event {
|
||||
|
||||
public $route;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use \FuzeWorks\Event;
|
||||
|
||||
class LayoutLoadEvent extends Event {
|
||||
|
||||
public $directory;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use \FuzeWorks\Event;
|
||||
|
||||
class ModelLoadEvent extends Event {
|
||||
|
||||
public $directory;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use \FuzeWorks\Event;
|
||||
|
||||
class RouterRouteEvent extends Event {
|
||||
|
||||
public $controller;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace FuzeWorks;
|
||||
|
||||
abstract class Bus {
|
||||
protected $core;
|
||||
protected $mods;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace FuzeWorks;
|
||||
|
||||
class Event {
|
||||
|
||||
private $cancelled = false;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace FuzeWorks;
|
||||
|
||||
/**
|
||||
* Class EventPriority
|
||||
*
|
||||
|
@ -1,5 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace FuzeWorks;
|
||||
|
||||
/**
|
||||
* Interface for a Module that gives abstract model types
|
||||
* A model server must contain the methods from this interface in order to correctly serve models
|
||||
*/
|
||||
interface ModelServer {
|
||||
public function giveModel($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract class Model
|
||||
*
|
||||
@ -28,11 +38,11 @@ abstract class Model extends Bus{
|
||||
* Set the type of this model. Eg, use techfuze/databasemodel and Databasemodel to get a SQL connected model
|
||||
* @access protected
|
||||
* @param String Module_name, the name of the module where the model can be found
|
||||
* @param String class name, the class to load and connect to
|
||||
* @param String Model_type, model type to return
|
||||
*/
|
||||
protected function setType($module_name, $class_name) {
|
||||
$this->core->loadMod($module_name);
|
||||
$this->parentClass = new $class_name($this->core);
|
||||
protected function setType($module_name, $model_type) {
|
||||
$mod = $this->core->loadMod($module_name);
|
||||
$this->parentClass = $mod->giveModel($model_type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace FuzeWorks;
|
||||
|
||||
/**
|
||||
* Class Module
|
||||
*
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace FuzeWorks;
|
||||
use \Exception;
|
||||
|
||||
/**
|
||||
* Config Module
|
||||
*
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace FuzeWorks;
|
||||
use \stdClass;
|
||||
use \Exception;
|
||||
|
||||
if (!defined('FUZESYSPATH')) {
|
||||
define('STARTTIME', microtime(true));
|
||||
define( 'FUZESYSPATH', dirname(__FILE__) . '/' );
|
||||
@ -131,11 +135,15 @@ class Core {
|
||||
$CLASS->setModulePath($cfg->directory);
|
||||
}
|
||||
if (method_exists($CLASS, 'setModuleLinkName')) {
|
||||
$CLASS->setModuleLinkName($cfg->name);
|
||||
$CLASS->setModuleLinkName(strtolower($cfg->module_name));
|
||||
}
|
||||
if (method_exists($CLASS, 'setModuleName')) {
|
||||
$CLASS->setModuleName($name);
|
||||
}
|
||||
|
||||
if (!method_exists($CLASS, 'onLoad')) {
|
||||
throw new Exception("Module '".$name."' does not have an onLoad() method! Invalid module", 1);
|
||||
}
|
||||
$CLASS->onLoad();
|
||||
|
||||
// Add to the loaded modules
|
||||
|
@ -4,6 +4,9 @@
|
||||
* @package files
|
||||
*/
|
||||
|
||||
namespace FuzeWorks;
|
||||
use \Exception;
|
||||
|
||||
/**
|
||||
* @name Events
|
||||
*/
|
||||
@ -84,10 +87,10 @@ class Events extends Bus{
|
||||
// No event arguments? Looks like an notify-event
|
||||
if(func_num_args() == 1){
|
||||
// Load notify-event-class
|
||||
$eventClass = 'NotifierEvent';
|
||||
$eventClass = '\FuzeWorks\NotifierEvent';
|
||||
}else{
|
||||
// No notify-event: we tried all we could
|
||||
throw new \Exception("Event ".$eventName." could not be found!");
|
||||
throw new Exception("Event ".$eventName." could not be found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace FuzeWorks;
|
||||
use \Exception;
|
||||
|
||||
class Layout extends Bus {
|
||||
|
||||
private $Smarty = array();
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace FuzeWorks;
|
||||
use \Exception;
|
||||
|
||||
class Logger extends Bus{
|
||||
|
||||
public $infoErrors = array();
|
||||
@ -113,6 +116,24 @@ class Logger extends Bus{
|
||||
}
|
||||
}
|
||||
|
||||
public function backtrace() {
|
||||
$e = new Exception();
|
||||
$trace = explode("\n", $e->getTraceAsString());
|
||||
// reverse array to make steps line up chronologically
|
||||
$trace = array_reverse($trace);
|
||||
array_shift($trace); // remove {main}
|
||||
array_pop($trace); // remove call to this method
|
||||
$length = count($trace);
|
||||
$result = array();
|
||||
|
||||
for ($i = 0; $i < $length; $i++)
|
||||
{
|
||||
$result[] = ($i + 1) . ')' . substr($trace[$i], strpos($trace[$i], ' ')); // replace '#someNum' with '$i)', set the right ordering
|
||||
}
|
||||
|
||||
return "\t" . implode("<br/>", $result);
|
||||
}
|
||||
|
||||
/* =========================================LOGGING METHODS==============================================================*/
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
* @author FuzeNetwork
|
||||
*/
|
||||
|
||||
namespace FuzeWorks;
|
||||
|
||||
class Models extends Bus{
|
||||
|
||||
private $models_array = array();
|
||||
@ -25,7 +27,7 @@ class Models extends Bus{
|
||||
$this->models_array[$name] = $this->model_types[$name];
|
||||
} elseif (file_exists($file)){
|
||||
require_once($file);
|
||||
$model = ucfirst($name);
|
||||
$model = "\Model\\" . ucfirst($name);
|
||||
$this->logger->logInfo('Loading Model: '.$model, $model);
|
||||
$this->models_array[$name] = new $model($this->core);
|
||||
} else{
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
|
||||
class Database extends Bus {
|
||||
use \FuzeWorks\Module;
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
|
||||
class Database extends Module {
|
||||
|
||||
private $DBH;
|
||||
public $prefix;
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
|
||||
class DatabaseModel extends Bus{
|
||||
namespace Module;
|
||||
use \FuzeWorks\Module;
|
||||
use \FuzeWorks\ModelServer;
|
||||
use \Exception;
|
||||
|
||||
class DatabaseModel extends Module implements ModelServer {
|
||||
|
||||
public $fields = array();
|
||||
public $primary = 'id';
|
||||
@ -8,7 +13,12 @@ class DatabaseModel extends Bus{
|
||||
|
||||
public function __construct(&$core){
|
||||
parent::__construct($core);
|
||||
$this->core->loadMod('database');
|
||||
}
|
||||
|
||||
public function onLoad() {}
|
||||
|
||||
public function giveModel($type) {
|
||||
return new DatabaseModel($this->core);
|
||||
}
|
||||
|
||||
public function select(){
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
return array(
|
||||
|
||||
'module_class' => 'DatabaseModel',
|
||||
'module_class' => 'Module\DatabaseModel',
|
||||
'module_file' => 'class.model.php',
|
||||
'module_name' => 'databasemodel',
|
||||
|
||||
'abstract' => true,
|
||||
'abstract' => false,
|
||||
'dependencies' => array('database'),
|
||||
|
||||
'name' => 'DatabaseModel',
|
||||
'description' => 'Abstract type for easy database queries',
|
||||
@ -15,4 +16,6 @@ return array(
|
||||
|
||||
'date_created' => '26-02-2015',
|
||||
'date_updated' => '26-02-2015',
|
||||
|
||||
'enabled' => true,
|
||||
);
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Router extends Bus {
|
||||
use \FuzeWorks\Module;
|
||||
|
||||
class Router extends Module {
|
||||
|
||||
public $controller = null;
|
||||
public $controllerName = null;
|
||||
@ -120,7 +122,7 @@ class Router extends Bus {
|
||||
if (!class_exists(ucfirst($this->controllerName)))
|
||||
require_once($file);
|
||||
|
||||
$this->controllerClass = ucfirst($this->controllerName);
|
||||
$this->controllerClass = "\Controller\\" . ucfirst($this->controllerName);
|
||||
$this->controller = new $this->controllerClass($this->core);
|
||||
|
||||
if (method_exists($this->controller, $this->function) || method_exists($this->controller, '__call')) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Module\Sections;
|
||||
use \Module;
|
||||
use \EventPriority;
|
||||
use \FuzeWorks\Module;
|
||||
use \FuzeWorks\EventPriority;
|
||||
|
||||
/**
|
||||
* Sections module, see usage documentation
|
||||
@ -64,9 +64,9 @@ class Main extends Module {
|
||||
$this->logger->stopLevel();
|
||||
|
||||
// Register Events
|
||||
$this->events->addListener(array($this, 'routerRouteEvent'), 'routerRouteEvent', EventPriority::NORMAL);
|
||||
$this->events->addListener(array($this, 'layoutLoadEvent'), 'layoutLoadEvent', EventPriority::NORMAL);
|
||||
$this->events->addListener(array($this, 'modelLoadevent'), 'modelLoadEvent', EventPriority::NORMAL);
|
||||
$this->events->addListener(array($this, 'routerRouteEvent'), 'routerRouteEvent', EventPriority::LOWEST);
|
||||
$this->events->addListener(array($this, 'layoutLoadEvent'), 'layoutLoadEvent', EventPriority::LOWEST);
|
||||
$this->events->addListener(array($this, 'modelLoadevent'), 'modelLoadEvent', EventPriority::LOWEST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,4 +17,6 @@ return array(
|
||||
|
||||
'date_created' => '29-04-2015',
|
||||
'date_updated' => '29-04-2015',
|
||||
|
||||
'enabled' => true,
|
||||
);
|
||||
|
@ -7,7 +7,7 @@ if (!defined('FUZEPATH')) {
|
||||
require_once( dirname(__FILE__) . "/Core/System/class.core.php");
|
||||
|
||||
// Load it
|
||||
$core = new Core();
|
||||
$core = new \FuzeWorks\Core();
|
||||
$core->init();
|
||||
$core->loadMod('router');
|
||||
$core->mods->router->setPath( (isset($_GET['path']) ? $_GET['path'] : null) );
|
||||
|
Loading…
Reference in New Issue
Block a user