Permalink
Browse files

Added a bootstrap to start supporting extensions

  • Loading branch information...
ivebeenlinuxed committed May 29, 2012
1 parent c01db72 commit 04422eea4e1cff6d0fc87be7c9c0e864ddca7535
Showing with 95 additions and 6 deletions.
  1. +73 −5 framework/system/core/Router.php
  2. +22 −1 framework/system/library/database/DBException.php
@@ -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 {
@@ -30,7 +34,15 @@
* @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
@@ -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));
@@ -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']));
+ }
+ }
}
@@ -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.