diff --git a/cake/libs/model/behavior.php b/cake/libs/model/behavior.php index 3d87ee805..0fceb1ec8 100644 --- a/cake/libs/model/behavior.php +++ b/cake/libs/model/behavior.php @@ -36,7 +36,6 @@ * @subpackage cake.cake.libs.model */ class ModelBehavior extends Object { - /** * Contains configuration settings for use with individual model objects. This * is used because if multiple models use this Behavior, each will use the same @@ -45,6 +44,7 @@ class ModelBehavior extends Object { * * @var array * @access public + * @see Model::$alias */ var $settings = array(); /** @@ -57,24 +57,79 @@ class ModelBehavior extends Object { * @access public */ var $mapMethods = array(); - - function setup(&$model, $config = array()) { } - - function beforeFind(&$model, $query) { } - - function afterFind(&$model, $results, $primary) { } - - function beforeValidate(&$model) { } - - function beforeSave(&$model) { } - - function afterSave(&$model, $created) { } - - function beforeDelete(&$model) { } - - function afterDelete(&$model) { } - - function onError(&$model, $error) { } +/** + * Setup this behavior with the specified configuration settings. + * + * @param object $Model Model using this behavior + * @param array $config Configuration settings for $Model + * @access public + */ + function setup(&$Model, $config = array()) { } +/** + * Before find callback + * + * @param object $Model Model using this behavior + * @param array $queryData Data used to execute this query, i.e. conditions, order, etc. + * @return boolean True if the operation should continue, false if it should abort + * @access public + */ + function beforeFind(&$Model, $query) { } +/** + * After find callback. Can be used to modify any results returned by find and findAll. + * + * @param object $Model Model using this behavior + * @param mixed $results The results of the find operation + * @param boolean $primary Whether this model is being queried directly (vs. being queried as an association) + * @return mixed Result of the find operation + * @access public + */ + function afterFind(&$Model, $results, $primary) { } +/** + * Before validate callback + * + * @param object $Model Model using this behavior + * @return boolean True if validate operation should continue, false to abort + * @access public + */ + function beforeValidate(&$Model) { } +/** + * Before save callback + * + * @param object $Model Model using this behavior + * @return boolean True if the operation should continue, false if it should abort + * @access public + */ + function beforeSave(&$Model) { } +/** + * After save callback + * + * @param object $Model Model using this behavior + * @param boolean $created True if this save created a new record + * @access public + */ + function afterSave(&$Model, $created) { } +/** + * Before delete callback + * + * @param object $Model Model using this behavior + * @return boolean True if the operation should continue, false if it should abort + * @access public + */ + function beforeDelete(&$Model) { } +/** + * After delete callback + * + * @param object $Model Model using this behavior + * @access public + */ + function afterDelete(&$Model) { } +/** + * DataSource error callback + * + * @param object $Model Model using this behavior + * @param string $error Error generated in DataSource + * @access public + */ + function onError(&$Model, $error) { } } - ?> \ No newline at end of file diff --git a/cake/libs/model/connection_manager.php b/cake/libs/model/connection_manager.php index ea055c4d5..1762afa7a 100644 --- a/cake/libs/model/connection_manager.php +++ b/cake/libs/model/connection_manager.php @@ -41,11 +41,10 @@ uses ('model' . DS . 'datasources' . DS . 'datasource'); config('database'); class ConnectionManager extends Object { - /** * Holds a loaded instance of the Connections object * - * @var class:Connections + * @var object * @access public */ var $config = null; @@ -69,19 +68,21 @@ class ConnectionManager extends Object { */ function __construct() { if (class_exists('DATABASE_CONFIG')) { - $this->config = new DATABASE_CONFIG(); + $this->config =& new DATABASE_CONFIG(); } } /** * Gets a reference to the ConnectionManger object instance * - * @return object + * @return object Instance + * @access public + * @static */ function &getInstance() { static $instance = array(); if (!isset($instance[0]) || !$instance[0]) { - $instance[0] = &new ConnectionManager(); + $instance[0] =& new ConnectionManager(); } return $instance[0]; @@ -90,7 +91,9 @@ class ConnectionManager extends Object { * Gets a reference to a DataSource object * * @param string $name The name of the DataSource, as defined in app/config/connections - * @return object + * @return object Instance + * @access public + * @static */ function &getDataSource($name) { $_this =& ConnectionManager::getInstance(); @@ -116,7 +119,9 @@ class ConnectionManager extends Object { /** * Gets the list of available DataSource connections * - * @return array + * @return array List of available connections + * @access public + * @static */ function sourceList() { $_this =& ConnectionManager::getInstance(); @@ -125,12 +130,13 @@ class ConnectionManager extends Object { /** * Gets a DataSource name from an object reference * - * @param object $source - * @return string + * @param object $source DataSource object + * @return string Datasource name + * @access public + * @static */ function getSourceName(&$source) { $_this =& ConnectionManager::getInstance(); - $names = array_keys($_this->_dataSources); for ($i = 0; $i < count($names); $i++) { if ($_this->_dataSources[$names[$i]] === $source) { @@ -145,6 +151,8 @@ class ConnectionManager extends Object { * @param mixed $connName A string name of the connection, as defined in Connections config, * or an array containing the file and class name of the object. * @return boolean True on success, null on failure or false if the class is already loaded + * @access public + * @static */ function loadDataSource($connName) { $_this =& ConnectionManager::getInstance(); @@ -178,6 +186,8 @@ class ConnectionManager extends Object { * * @return array An associative array of elements where the key is the connection name * (as defined in Connections), and the value is an array with keys 'filename' and 'classname'. + * @access public + * @static */ function enumConnectionObjects() { $_this =& ConnectionManager::getInstance(); @@ -202,6 +212,8 @@ class ConnectionManager extends Object { * @param string $name The DataSource name * @param array $config The DataSource configuration settings * @return object A reference to the DataSource object, or null if creation failed + * @access public + * @static */ function &create($name = '', $config = array()) { $_this =& ConnectionManager::getInstance(); @@ -216,9 +228,10 @@ class ConnectionManager extends Object { return $_this->getDataSource($name); } /** - * Private method + * Returns the file, class name, and parent for the given driver. * - * Returns the file and class name for the given driver + * @return array An indexed array with: filename, classname, and parent + * @access private */ function __getDriver($config) { $_this =& ConnectionManager::getInstance(); @@ -241,6 +254,7 @@ class ConnectionManager extends Object { /** * Destructor. * + * @access private */ function __destruct() { if (Configure::read('Session.save') == 'database' && function_exists('session_write_close')) {