Skip to content

Commit

Permalink
Added a bootstrap to start supporting extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ivebeenlinuxed committed May 29, 2012
1 parent c01db72 commit 04422ee
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 6 deletions.
78 changes: 73 additions & 5 deletions framework/system/core/Router.php
Expand Up @@ -3,8 +3,12 @@
/**
* Routes new requests to correct controller
*
* @author ivebeenlinuxed <will@bcslichfield.com>
* @link http://www.bcslichfield.com
* @category Core
* @package Boiler
* @author ivebeenlinuxed <will@bcslichfield.com>
* @license GNU v3.0 http://www.gnu.org/licenses/gpl-3.0.txt
* @version GIT: $Id$
* @link http://www.bcslichfield.com
*
*/
abstract class Router {
Expand All @@ -30,7 +34,15 @@ abstract class Router {
* @var array
*/
protected static $fofHandler = array("Controller\\ErrorDocument", "index");


/**
* Used to hold all the listeners registered via addListener function
*
* @var array
* @see \Core\Router::addListener
*/
protected static $listeners = array();

/**
*
* Get correct controller, using the argument array
Expand Down Expand Up @@ -66,13 +78,36 @@ public static function getController($controllerArray) {
return self::$fofHandler;
}

/**
* Initiates bootstraps and the config
*
* @return null
*/
public static function Init() {
if (file_exists(BOILER_LOCATION."../config.php")) {
require BOILER_LOCATION."../config.php";
include BOILER_LOCATION."../config.php";
self::$settings = $settings;
}

if (is_dir($bs = BOILER_LOCATION."application/bootstrap")) {
$dir = opendir($bs);
while (($file = readdir($dir)) !== false) {
if ($file == "." || $file == "..") {
continue;
}
include $bs."/".$file;
}
}
}



/**
* Get the error page
*
* @param int $error
*
* @return null
*/
public static function getErrorPage($error) {
$obj = new self::$fofHandler[0];
call_user_func_array(array($obj, self::$fofHandler[1]), array($error));
Expand Down Expand Up @@ -103,4 +138,37 @@ public static function loadHelper($helper, $variables=array()) {
}

}

/**
* Add a listener to the system
*
* @param string $signal Signal on which to activate
* @param mixed $callable A callable function
* @param array $param Parameters to append after event params
*
* @return null
*/
public static function addListener($signal, $callable, $param=array()) {
if (!isset(self::$listeners[$signal])) {
self::$listeners[$signal] = array();
}
self::$listeners[$signal] = array("callable"=>$callable, "param"=>$param);
}

/**
* Trigger an event in the system
*
* @param string $signal Signal to trigger
* @param array $param Event Arguments
*
* @return null
*/
public static function triggerEvent($signal, $param=array()) {
if (!isset(self::$listeners[$signal])) {
return;
}
foreach (self::$listeners[$signal] as $call) {
call_user_func($call['callable'], array_merge($param, $call['param']));
}
}
}
23 changes: 22 additions & 1 deletion framework/system/library/database/DBException.php
@@ -1,10 +1,31 @@
<?php
/**
* Dummy class to allow exceptions stemming from the framework to be handled specifically
*
* @author ivebeenlinuxed <will@bcslichfield.com>
* PHP Version: 5.3
*
* @category Core
* @package Boiler
* @author ivebeenlinuxed <will@bcslichfield.com>
* @license GNU v3.0 http://www.gnu.org/licenses/gpl-3.0.txt
* @version GIT: $Id$
* @link http://www.bcslichfield.com
*
*/
namespace Library\Database;

/**
* Dummy class to allow exceptions stemming from the framework to be handled specifically
*
* PHP Version: 5.3
*
* @category Core
* @package Boiler
* @author ivebeenlinuxed <will@bcslichfield.com>
* @license GNU v3.0 http://www.gnu.org/licenses/gpl-3.0.txt
* @link http://www.bcslichfield.com
*
*/
class DBException extends \Library\BoilerException {

}

0 comments on commit 04422ee

Please sign in to comment.