Permalink
Browse files

Renaming everything ASO_ to Bee_. Bzzz!

Added an app controller to override the framework controller and add app-central functions. A useful pattern!
Fixed up some code warts.
  • Loading branch information...
1 parent b4f7c68 commit 3229fec6c6765fe73c51648146cab790404699fe timdorr committed Jun 21, 2010
View
@@ -0,0 +1,8 @@
+<?php
+
+require_once 'Bee/Controller.php';
+
+class App_Controller extends Bee_Controller
+{
+
+}
View
@@ -30,8 +30,8 @@
set_include_path( "lib" . PATH_SEPARATOR . "app" . PATH_SEPARATOR . "var" . PATH_SEPARATOR . get_include_path() );
require_once 'Config.php';
-require_once 'ASO/Dispatch.php';
+require_once 'Bee/Dispatch.php';
-$dispatcher = new ASO_Dispatch();
+$dispatcher = new Bee_Dispatch();
//$dispatcher->throwExceptions(true);
$dispatcher->run();
@@ -28,29 +28,29 @@
*/
/**
- * @see ASO_Input
+ * @see Bee_Input
*/
-require_once 'ASO/Input.php';
+require_once 'Bee/Input.php';
/**
- * @see ASO_Db
+ * @see Bee_Db
*/
-require_once 'ASO/Db.php';
+require_once 'Bee/Db.php';
/**
- * @see ASO_Session
+ * @see Bee_Session
*/
-require_once 'ASO/Session.php';
+require_once 'Bee/Session.php';
/**
- * @see ASO_Error
+ * @see Bee_Error
*/
-require_once 'ASO/Error.php';
+require_once 'Bee/Error.php';
/**
- * @see ASO_Exception
+ * @see Bee_Exception
*/
-require_once 'ASO/Exception.php';
+require_once 'Bee/Exception.php';
/**
* Controller parent class.
@@ -60,7 +60,7 @@
* @copyright Copyright (c) Army of Bees (www.armyofbees.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
-class ASO_Controller
+class Bee_Controller
{
/**
* Application config
@@ -69,14 +69,14 @@ class ASO_Controller
protected $config = array();
/**
- * Processed input from ASO_Input::filter_input()
+ * Processed input from Bee_Input::filter_input()
* @var array
*/
protected $input = array();
/**
* Database connection
- * @var ASO_Db_Astract
+ * @var Bee_Db_Astract
*/
protected $db = array();
@@ -88,13 +88,13 @@ class ASO_Controller
/**
* Error storage
- * @var ASO_Error
+ * @var Bee_Error
*/
protected $error = null;
/**
* Session object
- * @var ASO_Session_Abstract
+ * @var Bee_Session_Abstract
*/
protected $_session = null;
@@ -122,30 +122,30 @@ public function __construct( $config )
{
// Verify that controller config is in an array.
if( !is_array( $config ) )
- throw new ASO_Controller_Exception('Controller configuraion must be in an array');
+ throw new Bee_Controller_Exception('Controller configuraion must be in an array');
$this->_setEnvironment();
$this->baseURL = $config['baseURL'];
$this->config = $config;
- $input =& ASO_Registry('input');
- $input = $this->input =& ASO_Input::filterInput();
+ $input =& Bee_Registry('input');
+ $input = $this->input =& Bee_Input::filterInput();
- $db =& ASO_Registry('db');
- $db = $this->db = ASO_Db::factory( $config['db_type'], $config );
+ $db =& Bee_Registry('db');
+ $db = $this->db = Bee_Db::factory( $config['db_type'], $config );
- $this->_session = ASO_Session::factory( $config['session_type'],
+ $this->_session = Bee_Session::factory( $config['session_type'],
array( 'db' => &$this->db,
'session_timeout' => $config['session_timeout'],
'session_domain' => $config['session_domain'],
'session_path' => $config['session_path'] ) );
- $sess =& ASO_Registry('sess');
+ $sess =& Bee_Registry('sess');
$sess = $this->_session->getData();
$this->sess =& $sess;
- $error =& ASO_Registry('error');
- $error = $this->error = new ASO_Error( $this );
+ $error =& Bee_Registry('error');
+ $error = $this->error = new Bee_Error( $this );
}
/**
@@ -196,7 +196,7 @@ public function _setup() { }
/**
* Default callback for logging runtime exceptions.
*
- * Override this method in a subclass of ASO_Controller
+ * Override this method in a subclass of Bee_Controller
* to log this error to someplace other than
* var/log/exceptions.log.
*
@@ -232,7 +232,7 @@ public function logException( $e )
/**
* Default callback for emailing runtime exceptions.
*
- * Override this method in a subclass of ASO_Controller
+ * Override this method in a subclass of Bee_Controller
* to change the default behavior.
*
* @param Exception $e The exception that was thrown at runtime
@@ -241,7 +241,7 @@ public function emailException( $e )
{
if( !isset($this->config['email_exceptions_address']) )
{
- throw new ASO_Controller_Exception( "Exception emailing turned on but no address specified. Please specify \$CONFIG['email_exceptions_address'] in app/Config.php" );
+ throw new Bee_Controller_Exception( "Exception emailing turned on but no address specified. Please specify \$CONFIG['email_exceptions_address'] in app/Config.php" );
}
$to = $from = $this->config['email_exceptions_address'];
@@ -270,5 +270,5 @@ public function emailException( $e )
}
-class ASO_Controller_Exception extends ASO_Exception
+class Bee_Controller_Exception extends Bee_Exception
{}
@@ -28,9 +28,9 @@
*/
/**
- * @see ASO_Exception
+ * @see Bee_Exception
*/
-require_once 'ASO/Exception.php';
+require_once 'Bee/Exception.php';
/**
* SQL Database abstraction layer.
@@ -40,34 +40,34 @@
* @copyright Copyright (c) Army of Bees (www.armyofbees.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
-class ASO_Db
+class Bee_Db
{
/**
* Creates the database adapter using the name passed.
*
* @param string $adapter The name of the adapter to use.
* @param array $config The configuration to pass to the adapter.
- * @return ASO_Db_Abstract
+ * @return Bee_Db_Abstract
*/
public static function factory( $adapter, $config = array() )
{
// Verify that adapter parameters are in an array.
if( !is_array( $config ) )
- throw new ASO_Db_Exception('Adapter parameters must be in an array');
+ throw new Bee_Db_Exception('Adapter parameters must be in an array');
// Verify that an adapter name has been specified.
if( !is_string( $adapter ) || empty( $adapter ) )
- throw new ASO_Db_Exception( 'Adapter name must be specified in a string' );
+ throw new Bee_Db_Exception( 'Adapter name must be specified in a string' );
// Load the adapter class.
- require_once 'ASO/Db/'.$adapter.'.php';
+ require_once 'Bee/Db/'.$adapter.'.php';
// Create an instance of the adapter, passing the config to it.
- $adapterName = 'ASO_Db_' . $adapter;
+ $adapterName = 'Bee_Db_' . $adapter;
return new $adapterName( $config );
}
}
-class ASO_Db_Exception extends ASO_Exception
+class Bee_Db_Exception extends Bee_Exception
{}
@@ -28,9 +28,9 @@
*/
/**
- * @see ASO_Exception
+ * @see Bee_Exception
*/
-require_once 'ASO/Exception.php';
+require_once 'Bee/Exception.php';
/**
* Abstract SQL database adapter class.
@@ -40,7 +40,7 @@
* @copyright Copyright (c) Army of Bees (www.armyofbees.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
-abstract class ASO_Db_Abstract
+abstract class Bee_Db_Abstract
{
/**
* The configuration to connect to the database
@@ -93,7 +93,7 @@ public function __construct( $config = array() )
{
// Verify that configuration is in an array.
if( !is_array( $config ) )
- throw new ASO_Db_Exception('Configuration must be in an array');
+ throw new Bee_Db_Exception('Configuration must be in an array');
$this->config = $config;
}
@@ -136,5 +136,5 @@ public function query( $query_string, $no_debug = false )
}
}
-class ASO_Db_Abstract_Exception extends ASO_Exception
+class Bee_Db_Abstract_Exception extends Bee_Exception
{}
@@ -28,9 +28,9 @@
*/
/**
- * @see ASO_Db_Abstract
+ * @see Bee_Db_Abstract
*/
-require_once 'ASO/Db/Abstract.php';
+require_once 'Bee/Db/Abstract.php';
/**
* MSSQL database adapter.
@@ -40,7 +40,7 @@
* @copyright Copyright (c) Army of Bees (www.armyofbees.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
-class ASO_Db_MSSQL extends ASO_Db_Abstract
+class Bee_Db_MSSQL extends Bee_Db_Abstract
{
/**
* Connects to the defined server and selects the defined database.
@@ -64,12 +64,12 @@ public function connect()
if ( !$this->_connection )
{
- throw new ASO_Db_MSSQL_Exception( "MSSQL Error: " . mssql_get_last_message() );
+ throw new Bee_Db_MSSQL_Exception( "MSSQL Error: " . mssql_get_last_message() );
}
if ( !mssql_select_db( $this->config['db_name'], $this->_connection ) )
{
- throw new ASO_Db_MSSQL_Exception( "MSSQL Error: " . mssql_get_last_message() );
+ throw new Bee_Db_MSSQL_Exception( "MSSQL Error: " . mssql_get_last_message() );
}
}
@@ -95,7 +95,7 @@ protected function _query( $query_string = "", $no_debug = false )
$this->_queryid = mssql_query( $query_string, $this->_connection );
if( !$this->_queryid )
- throw new ASO_Db_MSSQL_Exception("Could not compete a query to the database. MSSQL error: " . mssql_get_last_message() );
+ throw new Bee_Db_MSSQL_Exception("Could not compete a query to the database. MSSQL error: " . mssql_get_last_message() );
}
public function primary_table() {
@@ -397,5 +397,5 @@ public function __toString() {
}
-class ASO_Db_MSSQL_Exception extends ASO_Db_Abstract_Exception
+class Bee_Db_MSSQL_Exception extends Bee_Db_Abstract_Exception
{}
@@ -28,9 +28,9 @@
*/
/**
- * @see ASO_Db_Abstract
+ * @see Bee_Db_Abstract
*/
-require_once 'ASO/Db/Abstract.php';
+require_once 'Bee/Db/Abstract.php';
/**
* MySQL database adapter.
@@ -40,7 +40,7 @@
* @copyright Copyright (c) Army of Bees (www.armyofbees.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
-class ASO_Db_MySQL extends ASO_Db_Abstract
+class Bee_Db_MySQL extends Bee_Db_Abstract
{
/**
* Connects to the defined server and selects the defined database.
@@ -63,12 +63,12 @@ public function connect()
if ( !$this->_connection )
{
- throw new ASO_Db_MySQL_Exception( "MySQL Error: " . mysql_error() );
+ throw new Bee_Db_MySQL_Exception( "MySQL Error: " . mysql_error() );
}
if ( !mysql_select_db( $this->config['db_name'], $this->_connection ) )
{
- throw new ASO_Db_MySQL_Exception( "MySQL Error: " . mysql_error() );
+ throw new Bee_Db_MySQL_Exception( "MySQL Error: " . mysql_error() );
}
}
@@ -94,7 +94,7 @@ protected function _query( $query_string = "", $no_debug = false )
$this->_queryid = @mysql_query( $query_string, $this->_connection );
if( mysql_errno() != 0 )
- throw new ASO_Db_MySQL_Exception("Could not compete a query to the database. MySQL error: " . mysql_error() );
+ throw new Bee_Db_MySQL_Exception("Could not compete a query to the database. MySQL error: " . mysql_error() );
}
/**
@@ -594,5 +594,5 @@ public function __toString() {
}
-class ASO_Db_MySQL_Exception extends ASO_Db_Abstract_Exception
+class Bee_Db_MySQL_Exception extends Bee_Db_Abstract_Exception
{}
Oops, something went wrong.

0 comments on commit 3229fec

Please sign in to comment.