mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
type hinting models
This commit is contained in:
parent
22452f61f8
commit
45112088a1
11 changed files with 86 additions and 86 deletions
|
@ -44,7 +44,7 @@ class AclBehavior extends ModelBehavior {
|
||||||
* @param array $config
|
* @param array $config
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setup($model, $config = array()) {
|
public function setup(Model $model, $config = array()) {
|
||||||
if (isset($config[0])) {
|
if (isset($config[0])) {
|
||||||
$config['type'] = $config[0];
|
$config['type'] = $config[0];
|
||||||
unset($config[0]);
|
unset($config[0]);
|
||||||
|
@ -74,7 +74,7 @@ class AclBehavior extends ModelBehavior {
|
||||||
* @return array
|
* @return array
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/acl.html#node
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/acl.html#node
|
||||||
*/
|
*/
|
||||||
public function node($model, $ref = null, $type = null) {
|
public function node(Model $model, $ref = null, $type = null) {
|
||||||
if (empty($type)) {
|
if (empty($type)) {
|
||||||
$type = $this->_typeMaps[$this->settings[$model->name]['type']];
|
$type = $this->_typeMaps[$this->settings[$model->name]['type']];
|
||||||
if (is_array($type)) {
|
if (is_array($type)) {
|
||||||
|
@ -95,7 +95,7 @@ class AclBehavior extends ModelBehavior {
|
||||||
* @param boolean $created True if this is a new record
|
* @param boolean $created True if this is a new record
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterSave($model, $created) {
|
public function afterSave(Model $model, $created) {
|
||||||
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
|
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
|
||||||
if (!is_array($types)) {
|
if (!is_array($types)) {
|
||||||
$types = array($types);
|
$types = array($types);
|
||||||
|
@ -125,7 +125,7 @@ class AclBehavior extends ModelBehavior {
|
||||||
* @param Model $model
|
* @param Model $model
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterDelete($model) {
|
public function afterDelete(Model $model) {
|
||||||
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
|
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
|
||||||
if (!is_array($types)) {
|
if (!is_array($types)) {
|
||||||
$types = array($types);
|
$types = array($types);
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* @param array $settings Settings to override for model.
|
* @param array $settings Settings to override for model.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setup($Model, $settings = array()) {
|
public function setup(Model $Model, $settings = array()) {
|
||||||
if (!isset($this->settings[$Model->alias])) {
|
if (!isset($this->settings[$Model->alias])) {
|
||||||
$this->settings[$Model->alias] = array('recursive' => true, 'notices' => true, 'autoFields' => true);
|
$this->settings[$Model->alias] = array('recursive' => true, 'notices' => true, 'autoFields' => true);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* @param array $query Query parameters as set by cake
|
* @param array $query Query parameters as set by cake
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function beforeFind($Model, $query) {
|
public function beforeFind(Model $Model, $query) {
|
||||||
$reset = (isset($query['reset']) ? $query['reset'] : true);
|
$reset = (isset($query['reset']) ? $query['reset'] : true);
|
||||||
$noContain = (
|
$noContain = (
|
||||||
(isset($this->runtime[$Model->alias]['contain']) && empty($this->runtime[$Model->alias]['contain'])) ||
|
(isset($this->runtime[$Model->alias]['contain']) && empty($this->runtime[$Model->alias]['contain'])) ||
|
||||||
|
@ -225,7 +225,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* @return void
|
* @return void
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html#using-containable
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html#using-containable
|
||||||
*/
|
*/
|
||||||
public function contain($Model) {
|
public function contain(Model $Model) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$contain = call_user_func_array('am', array_slice($args, 1));
|
$contain = call_user_func_array('am', array_slice($args, 1));
|
||||||
$this->runtime[$Model->alias]['contain'] = $contain;
|
$this->runtime[$Model->alias]['contain'] = $contain;
|
||||||
|
@ -239,7 +239,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* @param Model $Model Model on which to reset bindings
|
* @param Model $Model Model on which to reset bindings
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function resetBindings($Model) {
|
public function resetBindings(Model $Model) {
|
||||||
if (!empty($Model->__backOriginalAssociation)) {
|
if (!empty($Model->__backOriginalAssociation)) {
|
||||||
$Model->__backAssociation = $Model->__backOriginalAssociation;
|
$Model->__backAssociation = $Model->__backOriginalAssociation;
|
||||||
unset($Model->__backOriginalAssociation);
|
unset($Model->__backOriginalAssociation);
|
||||||
|
@ -263,7 +263,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* @param boolean $throwErrors Whether non-existent bindings show throw errors
|
* @param boolean $throwErrors Whether non-existent bindings show throw errors
|
||||||
* @return array Containments
|
* @return array Containments
|
||||||
*/
|
*/
|
||||||
public function containments($Model, $contain, $containments = array(), $throwErrors = null) {
|
public function containments(Model $Model, $contain, $containments = array(), $throwErrors = null) {
|
||||||
$options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery');
|
$options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery');
|
||||||
$keep = array();
|
$keep = array();
|
||||||
if ($throwErrors === null) {
|
if ($throwErrors === null) {
|
||||||
|
@ -365,7 +365,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* @param mixed $fields If array, fields to initially load, if false use $Model as primary model
|
* @param mixed $fields If array, fields to initially load, if false use $Model as primary model
|
||||||
* @return array Fields
|
* @return array Fields
|
||||||
*/
|
*/
|
||||||
public function fieldDependencies($Model, $map, $fields = array()) {
|
public function fieldDependencies(Model $Model, $map, $fields = array()) {
|
||||||
if ($fields === false) {
|
if ($fields === false) {
|
||||||
foreach ($map as $parent => $children) {
|
foreach ($map as $parent => $children) {
|
||||||
foreach ($children as $type => $bindings) {
|
foreach ($children as $type => $bindings) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param array $config Array of configuration information.
|
* @param array $config Array of configuration information.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function setup($model, $config = array()) {
|
public function setup(Model $model, $config = array()) {
|
||||||
$db = ConnectionManager::getDataSource($model->useDbConfig);
|
$db = ConnectionManager::getDataSource($model->useDbConfig);
|
||||||
if (!$db->connected) {
|
if (!$db->connected) {
|
||||||
trigger_error(
|
trigger_error(
|
||||||
|
@ -84,7 +84,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param Model $model Model being detached.
|
* @param Model $model Model being detached.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function cleanup($model) {
|
public function cleanup(Model $model) {
|
||||||
$this->unbindTranslation($model);
|
$this->unbindTranslation($model);
|
||||||
unset($this->settings[$model->alias]);
|
unset($this->settings[$model->alias]);
|
||||||
unset($this->runtime[$model->alias]);
|
unset($this->runtime[$model->alias]);
|
||||||
|
@ -97,7 +97,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param array $query Array of Query parameters.
|
* @param array $query Array of Query parameters.
|
||||||
* @return array Modified query
|
* @return array Modified query
|
||||||
*/
|
*/
|
||||||
public function beforeFind($model, $query) {
|
public function beforeFind(Model $model, $query) {
|
||||||
$this->runtime[$model->alias]['virtualFields'] = $model->virtualFields;
|
$this->runtime[$model->alias]['virtualFields'] = $model->virtualFields;
|
||||||
$locale = $this->_getLocale($model);
|
$locale = $this->_getLocale($model);
|
||||||
if (empty($locale)) {
|
if (empty($locale)) {
|
||||||
|
@ -263,7 +263,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param boolean $primary Did the find originate on $model.
|
* @param boolean $primary Did the find originate on $model.
|
||||||
* @return array Modified results
|
* @return array Modified results
|
||||||
*/
|
*/
|
||||||
public function afterFind($model, $results, $primary) {
|
public function afterFind(Model $model, $results, $primary) {
|
||||||
$model->virtualFields = $this->runtime[$model->alias]['virtualFields'];
|
$model->virtualFields = $this->runtime[$model->alias]['virtualFields'];
|
||||||
$this->runtime[$model->alias]['virtualFields'] = $this->runtime[$model->alias]['fields'] = array();
|
$this->runtime[$model->alias]['virtualFields'] = $this->runtime[$model->alias]['fields'] = array();
|
||||||
$locale = $this->_getLocale($model);
|
$locale = $this->_getLocale($model);
|
||||||
|
@ -309,7 +309,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param Model $model Model invalidFields was called on.
|
* @param Model $model Model invalidFields was called on.
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function beforeValidate($model) {
|
public function beforeValidate(Model $model) {
|
||||||
$locale = $this->_getLocale($model);
|
$locale = $this->_getLocale($model);
|
||||||
if (empty($locale)) {
|
if (empty($locale)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -343,7 +343,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param boolean $created Whether or not the save created a record.
|
* @param boolean $created Whether or not the save created a record.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterSave($model, $created) {
|
public function afterSave(Model $model, $created) {
|
||||||
if (!isset($this->runtime[$model->alias]['beforeSave'])) {
|
if (!isset($this->runtime[$model->alias]['beforeSave'])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param Model $model Model the callback was run on.
|
* @param Model $model Model the callback was run on.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterDelete($model) {
|
public function afterDelete(Model $model) {
|
||||||
$RuntimeModel = $this->translateModel($model);
|
$RuntimeModel = $this->translateModel($model);
|
||||||
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
|
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
|
||||||
$RuntimeModel->deleteAll($conditions);
|
$RuntimeModel->deleteAll($conditions);
|
||||||
|
@ -398,7 +398,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param Model $model Model the locale needs to be set/get on.
|
* @param Model $model Model the locale needs to be set/get on.
|
||||||
* @return mixed string or false
|
* @return mixed string or false
|
||||||
*/
|
*/
|
||||||
protected function _getLocale($model) {
|
protected function _getLocale(Model $model) {
|
||||||
if (!isset($model->locale) || is_null($model->locale)) {
|
if (!isset($model->locale) || is_null($model->locale)) {
|
||||||
$I18n = I18n::getInstance();
|
$I18n = I18n::getInstance();
|
||||||
$I18n->l10n->get(Configure::read('Config.language'));
|
$I18n->l10n->get(Configure::read('Config.language'));
|
||||||
|
@ -417,7 +417,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param Model $model Model to get a translatemodel for.
|
* @param Model $model Model to get a translatemodel for.
|
||||||
* @return Model
|
* @return Model
|
||||||
*/
|
*/
|
||||||
public function translateModel($model) {
|
public function translateModel(Model $model) {
|
||||||
if (!isset($this->runtime[$model->alias]['model'])) {
|
if (!isset($this->runtime[$model->alias]['model'])) {
|
||||||
if (!isset($model->translateModel) || empty($model->translateModel)) {
|
if (!isset($model->translateModel) || empty($model->translateModel)) {
|
||||||
$className = 'I18nModel';
|
$className = 'I18nModel';
|
||||||
|
@ -447,7 +447,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @param boolean $reset
|
* @param boolean $reset
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function bindTranslation($model, $fields, $reset = true) {
|
public function bindTranslation(Model $model, $fields, $reset = true) {
|
||||||
if (is_string($fields)) {
|
if (is_string($fields)) {
|
||||||
$fields = array($fields);
|
$fields = array($fields);
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* unbind all original translations
|
* unbind all original translations
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function unbindTranslation($model, $fields = null) {
|
public function unbindTranslation(Model $model, $fields = null) {
|
||||||
if (empty($fields) && empty($this->settings[$model->alias])) {
|
if (empty($fields) && empty($this->settings[$model->alias])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @param array $config array of configuration settings.
|
* @param array $config array of configuration settings.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setup($Model, $config = array()) {
|
public function setup(Model $Model, $config = array()) {
|
||||||
if (isset($config[0])) {
|
if (isset($config[0])) {
|
||||||
$config['type'] = $config[0];
|
$config['type'] = $config[0];
|
||||||
unset($config[0]);
|
unset($config[0]);
|
||||||
|
@ -80,7 +80,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @param boolean $created indicates whether the node just saved was created or updated
|
* @param boolean $created indicates whether the node just saved was created or updated
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
public function afterSave($Model, $created) {
|
public function afterSave(Model $Model, $created) {
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
if ($created) {
|
if ($created) {
|
||||||
if ((isset($Model->data[$Model->alias][$parent])) && $Model->data[$Model->alias][$parent]) {
|
if ((isset($Model->data[$Model->alias][$parent])) && $Model->data[$Model->alias][$parent]) {
|
||||||
|
@ -99,7 +99,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @param array $query Query parameters as set by cake
|
* @param array $query Query parameters as set by cake
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function beforeFind($Model, $query) {
|
public function beforeFind(Model $Model, $query) {
|
||||||
if ($Model->findQueryType == 'threaded' && !isset($query['parent'])) {
|
if ($Model->findQueryType == 'threaded' && !isset($query['parent'])) {
|
||||||
$query['parent'] = $this->settings[$Model->alias]['parent'];
|
$query['parent'] = $this->settings[$Model->alias]['parent'];
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @param boolean $cascade
|
* @param boolean $cascade
|
||||||
* @return boolean true to continue, false to abort the delete
|
* @return boolean true to continue, false to abort the delete
|
||||||
*/
|
*/
|
||||||
public function beforeDelete($Model, $cascade = true) {
|
public function beforeDelete(Model $Model, $cascade = true) {
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
$data = current($Model->find('first', array(
|
$data = current($Model->find('first', array(
|
||||||
'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
|
'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
|
||||||
|
@ -149,7 +149,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @param Model $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @return boolean true to continue, false to abort the save
|
* @return boolean true to continue, false to abort the save
|
||||||
*/
|
*/
|
||||||
public function beforeSave($Model) {
|
public function beforeSave(Model $Model) {
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
|
|
||||||
$this->_addToWhitelist($Model, array($left, $right));
|
$this->_addToWhitelist($Model, array($left, $right));
|
||||||
|
@ -219,7 +219,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return integer number of child nodes
|
* @return integer number of child nodes
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::childCount
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::childCount
|
||||||
*/
|
*/
|
||||||
public function childCount($Model, $id = null, $direct = false) {
|
public function childCount(Model $Model, $id = null, $direct = false) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge(array('id' => null), $id));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return array Array of child nodes
|
* @return array Array of child nodes
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::children
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::children
|
||||||
*/
|
*/
|
||||||
public function children($Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
|
public function children(Model $Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge(array('id' => null), $id));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return array An associative array of records, where the id is the key, and the display field is the value
|
* @return array An associative array of records, where the id is the key, and the display field is the value
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::generateTreeList
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::generateTreeList
|
||||||
*/
|
*/
|
||||||
public function generateTreeList($Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
|
public function generateTreeList(Model $Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
|
||||||
$overrideRecursive = $recursive;
|
$overrideRecursive = $recursive;
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
if (!is_null($overrideRecursive)) {
|
if (!is_null($overrideRecursive)) {
|
||||||
|
@ -378,7 +378,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return array|boolean Array of data for the parent node
|
* @return array|boolean Array of data for the parent node
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getParentNode
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getParentNode
|
||||||
*/
|
*/
|
||||||
public function getParentNode($Model, $id = null, $fields = null, $recursive = null) {
|
public function getParentNode(Model $Model, $id = null, $fields = null, $recursive = null) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge(array('id' => null), $id));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
|
@ -411,7 +411,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return array Array of nodes from top most parent to current node
|
* @return array Array of nodes from top most parent to current node
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getPath
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getPath
|
||||||
*/
|
*/
|
||||||
public function getPath($Model, $id = null, $fields = null, $recursive = null) {
|
public function getPath(Model $Model, $id = null, $fields = null, $recursive = null) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge(array('id' => null), $id));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveDown
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveDown
|
||||||
*/
|
*/
|
||||||
public function moveDown($Model, $id = null, $number = 1) {
|
public function moveDown(Model $Model, $id = null, $number = 1) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge(array('id' => null), $id));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveUp
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveUp
|
||||||
*/
|
*/
|
||||||
public function moveUp($Model, $id = null, $number = 1) {
|
public function moveUp(Model $Model, $id = null, $number = 1) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge(array('id' => null), $id));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::recover
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::recover
|
||||||
*/
|
*/
|
||||||
public function recover($Model, $mode = 'parent', $missingParentAction = null) {
|
public function recover(Model $Model, $mode = 'parent', $missingParentAction = null) {
|
||||||
if (is_array($mode)) {
|
if (is_array($mode)) {
|
||||||
extract (array_merge(array('mode' => 'parent'), $mode));
|
extract (array_merge(array('mode' => 'parent'), $mode));
|
||||||
}
|
}
|
||||||
|
@ -649,7 +649,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::reorder
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::reorder
|
||||||
*/
|
*/
|
||||||
public function reorder($Model, $options = array()) {
|
public function reorder(Model $Model, $options = array()) {
|
||||||
$options = array_merge(array('id' => null, 'field' => $Model->displayField, 'order' => 'ASC', 'verify' => true), $options);
|
$options = array_merge(array('id' => null, 'field' => $Model->displayField, 'order' => 'ASC', 'verify' => true), $options);
|
||||||
extract($options);
|
extract($options);
|
||||||
if ($verify && !$this->verify($Model)) {
|
if ($verify && !$this->verify($Model)) {
|
||||||
|
@ -688,7 +688,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::removeFromTree
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::removeFromTree
|
||||||
*/
|
*/
|
||||||
public function removeFromTree($Model, $id = null, $delete = false) {
|
public function removeFromTree(Model $Model, $id = null, $delete = false) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge(array('id' => null), $id));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
|
@ -759,7 +759,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* [incorrect left/right index,node id], message)
|
* [incorrect left/right index,node id], message)
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::verify
|
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::verify
|
||||||
*/
|
*/
|
||||||
public function verify($Model) {
|
public function verify(Model $Model) {
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
if (!$Model->find('count', array('conditions' => $scope))) {
|
if (!$Model->find('count', array('conditions' => $scope))) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -831,7 +831,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @param boolean $created
|
* @param boolean $created
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
protected function _setParent($Model, $parentId = null, $created = false) {
|
protected function _setParent(Model $Model, $parentId = null, $created = false) {
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
list($node) = array_values($Model->find('first', array(
|
list($node) = array_values($Model->find('first', array(
|
||||||
'conditions' => array($scope, $Model->escapeField() => $Model->id),
|
'conditions' => array($scope, $Model->escapeField() => $Model->id),
|
||||||
|
@ -903,7 +903,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @param boolean $created
|
* @param boolean $created
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
protected function _getMax($Model, $scope, $right, $recursive = -1, $created = false) {
|
protected function _getMax(Model $Model, $scope, $right, $recursive = -1, $created = false) {
|
||||||
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
||||||
if ($created) {
|
if ($created) {
|
||||||
if (is_string($scope)) {
|
if (is_string($scope)) {
|
||||||
|
@ -931,7 +931,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @param integer $recursive
|
* @param integer $recursive
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
protected function _getMin($Model, $scope, $left, $recursive = -1) {
|
protected function _getMin(Model $Model, $scope, $left, $recursive = -1) {
|
||||||
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
||||||
$name = $Model->alias . '.' . $left;
|
$name = $Model->alias . '.' . $left;
|
||||||
list($edge) = array_values($Model->find('first', array(
|
list($edge) = array_values($Model->find('first', array(
|
||||||
|
@ -955,7 +955,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @param string $field
|
* @param string $field
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _sync($Model, $shift, $dir = '+', $conditions = array(), $created = false, $field = 'both') {
|
protected function _sync(Model $Model, $shift, $dir = '+', $conditions = array(), $created = false, $field = 'both') {
|
||||||
$ModelRecursive = $Model->recursive;
|
$ModelRecursive = $Model->recursive;
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
$Model->recursive = $recursive;
|
$Model->recursive = $recursive;
|
||||||
|
|
|
@ -348,7 +348,7 @@ class Postgres extends DboSource {
|
||||||
* @param boolean $quote
|
* @param boolean $quote
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fields($model, $alias = null, $fields = array(), $quote = true) {
|
public function fields(Model $model, $alias = null, $fields = array(), $quote = true) {
|
||||||
if (empty($alias)) {
|
if (empty($alias)) {
|
||||||
$alias = $model->alias;
|
$alias = $model->alias;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ class Sqlserver extends DboSource {
|
||||||
* @param boolean $quote
|
* @param boolean $quote
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fields($model, $alias = null, $fields = array(), $quote = true) {
|
public function fields(Model $model, $alias = null, $fields = array(), $quote = true) {
|
||||||
if (empty($alias)) {
|
if (empty($alias)) {
|
||||||
$alias = $model->alias;
|
$alias = $model->alias;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1149,7 +1149,7 @@ class DboSource extends DataSource {
|
||||||
* @param array $stack
|
* @param array $stack
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
|
public function queryAssociation(Model $model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
|
||||||
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
|
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
|
||||||
if (!is_array($resultSet)) {
|
if (!is_array($resultSet)) {
|
||||||
throw new CakeException(__d('cake_dev', 'Error in Model %s', get_class($model)));
|
throw new CakeException(__d('cake_dev', 'Error in Model %s', get_class($model)));
|
||||||
|
@ -1291,7 +1291,7 @@ class DboSource extends DataSource {
|
||||||
* @param array $ids Array of IDs of associated records
|
* @param array $ids Array of IDs of associated records
|
||||||
* @return array Association results
|
* @return array Association results
|
||||||
*/
|
*/
|
||||||
public function fetchAssociated($model, $query, $ids) {
|
public function fetchAssociated(Model $model, $query, $ids) {
|
||||||
$query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query);
|
$query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query);
|
||||||
if (count($ids) > 1) {
|
if (count($ids) > 1) {
|
||||||
$query = str_replace('= (', 'IN (', $query);
|
$query = str_replace('= (', 'IN (', $query);
|
||||||
|
@ -1435,7 +1435,7 @@ class DboSource extends DataSource {
|
||||||
* @param array $resultSet
|
* @param array $resultSet
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function generateAssociationQuery($model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
|
public function generateAssociationQuery(Model $model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
|
||||||
$queryData = $this->_scrubQueryData($queryData);
|
$queryData = $this->_scrubQueryData($queryData);
|
||||||
$assocData = $this->_scrubQueryData($assocData);
|
$assocData = $this->_scrubQueryData($assocData);
|
||||||
$modelAlias = $model->alias;
|
$modelAlias = $model->alias;
|
||||||
|
@ -1812,7 +1812,7 @@ class DboSource extends DataSource {
|
||||||
* @param boolean $alias Include the model alias in the field name
|
* @param boolean $alias Include the model alias in the field name
|
||||||
* @return array Fields and values, quoted and prepared
|
* @return array Fields and values, quoted and prepared
|
||||||
*/
|
*/
|
||||||
protected function _prepareUpdateFields($model, $fields, $quoteValues = true, $alias = false) {
|
protected function _prepareUpdateFields(Model $model, $fields, $quoteValues = true, $alias = false) {
|
||||||
$quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
|
$quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
|
||||||
|
|
||||||
$updates = array();
|
$updates = array();
|
||||||
|
@ -1879,7 +1879,7 @@ class DboSource extends DataSource {
|
||||||
* @param mixed $conditions
|
* @param mixed $conditions
|
||||||
* @return array List of record IDs
|
* @return array List of record IDs
|
||||||
*/
|
*/
|
||||||
protected function _matchRecords($model, $conditions = null) {
|
protected function _matchRecords(Model $model, $conditions = null) {
|
||||||
if ($conditions === true) {
|
if ($conditions === true) {
|
||||||
$conditions = $this->conditions(true);
|
$conditions = $this->conditions(true);
|
||||||
} elseif ($conditions === null) {
|
} elseif ($conditions === null) {
|
||||||
|
@ -1926,7 +1926,7 @@ class DboSource extends DataSource {
|
||||||
* @param Model $model
|
* @param Model $model
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function _getJoins($model) {
|
protected function _getJoins(Model $model) {
|
||||||
$join = array();
|
$join = array();
|
||||||
$joins = array_merge($model->getAssociated('hasOne'), $model->getAssociated('belongsTo'));
|
$joins = array_merge($model->getAssociated('hasOne'), $model->getAssociated('belongsTo'));
|
||||||
|
|
||||||
|
@ -1955,7 +1955,7 @@ class DboSource extends DataSource {
|
||||||
* @param array $params Function parameters (any values must be quoted manually)
|
* @param array $params Function parameters (any values must be quoted manually)
|
||||||
* @return string An SQL calculation function
|
* @return string An SQL calculation function
|
||||||
*/
|
*/
|
||||||
public function calculate($model, $func, $params = array()) {
|
public function calculate(Model $model, $func, $params = array()) {
|
||||||
$params = (array)$params;
|
$params = (array)$params;
|
||||||
|
|
||||||
switch (strtolower($func)) {
|
switch (strtolower($func)) {
|
||||||
|
@ -2083,7 +2083,7 @@ class DboSource extends DataSource {
|
||||||
* @see DboSource::update()
|
* @see DboSource::update()
|
||||||
* @see DboSource::conditions()
|
* @see DboSource::conditions()
|
||||||
*/
|
*/
|
||||||
public function defaultConditions($model, $conditions, $useAlias = true) {
|
public function defaultConditions(Model $model, $conditions, $useAlias = true) {
|
||||||
if (!empty($conditions)) {
|
if (!empty($conditions)) {
|
||||||
return $conditions;
|
return $conditions;
|
||||||
}
|
}
|
||||||
|
@ -2139,7 +2139,7 @@ class DboSource extends DataSource {
|
||||||
* @param mixed $fields virtual fields to be used on query
|
* @param mixed $fields virtual fields to be used on query
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function _constructVirtualFields($model, $alias, $fields) {
|
protected function _constructVirtualFields(Model $model, $alias, $fields) {
|
||||||
$virtual = array();
|
$virtual = array();
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$virtualField = $this->name($alias . $this->virtualFieldSeparator . $field);
|
$virtualField = $this->name($alias . $this->virtualFieldSeparator . $field);
|
||||||
|
@ -2158,7 +2158,7 @@ class DboSource extends DataSource {
|
||||||
* @param boolean $quote If false, returns fields array unquoted
|
* @param boolean $quote If false, returns fields array unquoted
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fields($model, $alias = null, $fields = array(), $quote = true) {
|
public function fields(Model $model, $alias = null, $fields = array(), $quote = true) {
|
||||||
if (empty($alias)) {
|
if (empty($alias)) {
|
||||||
$alias = $model->alias;
|
$alias = $model->alias;
|
||||||
}
|
}
|
||||||
|
@ -2673,7 +2673,7 @@ class DboSource extends DataSource {
|
||||||
* @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
|
* @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
|
||||||
* @return boolean True if the table has a matching record, else false
|
* @return boolean True if the table has a matching record, else false
|
||||||
*/
|
*/
|
||||||
public function hasAny($Model, $sql) {
|
public function hasAny(Model $Model, $sql) {
|
||||||
$sql = $this->conditions($sql);
|
$sql = $this->conditions($sql);
|
||||||
$table = $this->fullTableName($Model);
|
$table = $this->fullTableName($Model);
|
||||||
$alias = $this->alias . $this->name($Model->alias);
|
$alias = $this->alias . $this->name($Model->alias);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
* the model instance to be shifted onto the parameter list.
|
* the model instance to be shifted onto the parameter list.
|
||||||
*
|
*
|
||||||
* {{{
|
* {{{
|
||||||
* function doSomething($model, $arg1, $arg2) {
|
* function doSomething(Model $model, $arg1, $arg2) {
|
||||||
* //do something
|
* //do something
|
||||||
* }
|
* }
|
||||||
* }}}
|
* }}}
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
* {{{
|
* {{{
|
||||||
* public $mapMethods = array('/do(\w+)/' => 'doSomething');
|
* public $mapMethods = array('/do(\w+)/' => 'doSomething');
|
||||||
*
|
*
|
||||||
* function doSomething($model, $method, $arg1, $arg2) {
|
* function doSomething(Model $model, $method, $arg1, $arg2) {
|
||||||
* //do something
|
* //do something
|
||||||
* }
|
* }
|
||||||
* }}}
|
* }}}
|
||||||
|
@ -92,7 +92,7 @@ class ModelBehavior extends Object {
|
||||||
* @param array $config Configuration settings for $model
|
* @param array $config Configuration settings for $model
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setup($model, $config = array()) { }
|
public function setup(Model $model, $config = array()) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up any initialization this behavior has done on a model. Called when a behavior is dynamically
|
* Clean up any initialization this behavior has done on a model. Called when a behavior is dynamically
|
||||||
|
@ -102,7 +102,7 @@ class ModelBehavior extends Object {
|
||||||
* @return void
|
* @return void
|
||||||
* @see BehaviorCollection::detach()
|
* @see BehaviorCollection::detach()
|
||||||
*/
|
*/
|
||||||
public function cleanup($model) {
|
public function cleanup(Model $model) {
|
||||||
if (isset($this->settings[$model->alias])) {
|
if (isset($this->settings[$model->alias])) {
|
||||||
unset($this->settings[$model->alias]);
|
unset($this->settings[$model->alias]);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ class ModelBehavior extends Object {
|
||||||
* @return boolean|array False or null will abort the operation. You can return an array to replace the
|
* @return boolean|array False or null will abort the operation. You can return an array to replace the
|
||||||
* $query that will be eventually run.
|
* $query that will be eventually run.
|
||||||
*/
|
*/
|
||||||
public function beforeFind($model, $query) {
|
public function beforeFind(Model $model, $query) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class ModelBehavior extends Object {
|
||||||
* @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
|
* @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
|
||||||
* @return mixed An array value will replace the value of $results - any other value will be ignored.
|
* @return mixed An array value will replace the value of $results - any other value will be ignored.
|
||||||
*/
|
*/
|
||||||
public function afterFind($model, $results, $primary) { }
|
public function afterFind(Model $model, $results, $primary) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* beforeValidate is called before a model is validated, you can use this callback to
|
* beforeValidate is called before a model is validated, you can use this callback to
|
||||||
|
@ -140,7 +140,7 @@ class ModelBehavior extends Object {
|
||||||
* @param Model $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @return mixed False or null will abort the operation. Any other result will continue.
|
* @return mixed False or null will abort the operation. Any other result will continue.
|
||||||
*/
|
*/
|
||||||
public function beforeValidate($model) {
|
public function beforeValidate(Model $model) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ class ModelBehavior extends Object {
|
||||||
* @param Model $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @return mixed False if the operation should abort. Any other result will continue.
|
* @return mixed False if the operation should abort. Any other result will continue.
|
||||||
*/
|
*/
|
||||||
public function beforeSave($model) {
|
public function beforeSave(Model $model) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class ModelBehavior extends Object {
|
||||||
* @param boolean $created True if this save created a new record
|
* @param boolean $created True if this save created a new record
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function afterSave($model, $created) {
|
public function afterSave(Model $model, $created) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ class ModelBehavior extends Object {
|
||||||
* @param boolean $cascade If true records that depend on this record will also be deleted
|
* @param boolean $cascade If true records that depend on this record will also be deleted
|
||||||
* @return mixed False if the operation should abort. Any other result will continue.
|
* @return mixed False if the operation should abort. Any other result will continue.
|
||||||
*/
|
*/
|
||||||
public function beforeDelete($model, $cascade = true) {
|
public function beforeDelete(Model $model, $cascade = true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ class ModelBehavior extends Object {
|
||||||
* @param Model $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterDelete($model) { }
|
public function afterDelete(Model $model) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DataSource error callback
|
* DataSource error callback
|
||||||
|
@ -193,7 +193,7 @@ class ModelBehavior extends Object {
|
||||||
* @param string $error Error generated in DataSource
|
* @param string $error Error generated in DataSource
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onError($model, $error) { }
|
public function onError(Model $model, $error) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If $model's whitelist property is non-empty, $field will be added to it.
|
* If $model's whitelist property is non-empty, $field will be added to it.
|
||||||
|
@ -205,7 +205,7 @@ class ModelBehavior extends Object {
|
||||||
* @param string $field Field to be added to $model's whitelist
|
* @param string $field Field to be added to $model's whitelist
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _addToWhitelist($model, $field) {
|
protected function _addToWhitelist(Model $model, $field) {
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
foreach ($field as $f) {
|
foreach ($field as $f) {
|
||||||
$this->_addToWhitelist($model, $f);
|
$this->_addToWhitelist($model, $f);
|
||||||
|
|
|
@ -3644,7 +3644,7 @@ class ContainableBehaviorTest extends CakeTestCase {
|
||||||
* @param array $expected
|
* @param array $expected
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _assertBindings($Model, $expected = array()) {
|
protected function _assertBindings(Model $Model, $expected = array()) {
|
||||||
$expected = array_merge(array(
|
$expected = array_merge(array(
|
||||||
'belongsTo' => array(),
|
'belongsTo' => array(),
|
||||||
'hasOne' => array(),
|
'hasOne' => array(),
|
||||||
|
|
|
@ -43,7 +43,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param array $config
|
* @param array $config
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setup($model, $config = array()) {
|
public function setup(Model $model, $config = array()) {
|
||||||
parent::setup($model, $config);
|
parent::setup($model, $config);
|
||||||
if (isset($config['mangle'])) {
|
if (isset($config['mangle'])) {
|
||||||
$config['mangle'] .= ' mangled';
|
$config['mangle'] .= ' mangled';
|
||||||
|
@ -58,7 +58,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param mixed $query
|
* @param mixed $query
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function beforeFind($model, $query) {
|
public function beforeFind(Model $model, $query) {
|
||||||
$settings = $this->settings[$model->alias];
|
$settings = $this->settings[$model->alias];
|
||||||
if (!isset($settings['beforeFind']) || $settings['beforeFind'] == 'off') {
|
if (!isset($settings['beforeFind']) || $settings['beforeFind'] == 'off') {
|
||||||
return parent::beforeFind($model, $query);
|
return parent::beforeFind($model, $query);
|
||||||
|
@ -86,7 +86,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param mixed $primary
|
* @param mixed $primary
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterFind($model, $results, $primary) {
|
public function afterFind(Model $model, $results, $primary) {
|
||||||
$settings = $this->settings[$model->alias];
|
$settings = $this->settings[$model->alias];
|
||||||
if (!isset($settings['afterFind']) || $settings['afterFind'] == 'off') {
|
if (!isset($settings['afterFind']) || $settings['afterFind'] == 'off') {
|
||||||
return parent::afterFind($model, $results, $primary);
|
return parent::afterFind($model, $results, $primary);
|
||||||
|
@ -113,7 +113,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param mixed $model
|
* @param mixed $model
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function beforeSave($model) {
|
public function beforeSave(Model $model) {
|
||||||
$settings = $this->settings[$model->alias];
|
$settings = $this->settings[$model->alias];
|
||||||
if (!isset($settings['beforeSave']) || $settings['beforeSave'] == 'off') {
|
if (!isset($settings['beforeSave']) || $settings['beforeSave'] == 'off') {
|
||||||
return parent::beforeSave($model);
|
return parent::beforeSave($model);
|
||||||
|
@ -139,7 +139,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param mixed $created
|
* @param mixed $created
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterSave($model, $created) {
|
public function afterSave(Model $model, $created) {
|
||||||
$settings = $this->settings[$model->alias];
|
$settings = $this->settings[$model->alias];
|
||||||
if (!isset($settings['afterSave']) || $settings['afterSave'] == 'off') {
|
if (!isset($settings['afterSave']) || $settings['afterSave'] == 'off') {
|
||||||
return parent::afterSave($model, $created);
|
return parent::afterSave($model, $created);
|
||||||
|
@ -170,7 +170,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param mixed $model
|
* @param mixed $model
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function beforeValidate($model) {
|
public function beforeValidate(Model $model) {
|
||||||
$settings = $this->settings[$model->alias];
|
$settings = $this->settings[$model->alias];
|
||||||
if (!isset($settings['validate']) || $settings['validate'] == 'off') {
|
if (!isset($settings['validate']) || $settings['validate'] == 'off') {
|
||||||
return parent::beforeValidate($model);
|
return parent::beforeValidate($model);
|
||||||
|
@ -201,7 +201,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param bool $cascade
|
* @param bool $cascade
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function beforeDelete($model, $cascade = true) {
|
public function beforeDelete(Model $model, $cascade = true) {
|
||||||
$settings = $this->settings[$model->alias];
|
$settings = $this->settings[$model->alias];
|
||||||
if (!isset($settings['beforeDelete']) || $settings['beforeDelete'] == 'off') {
|
if (!isset($settings['beforeDelete']) || $settings['beforeDelete'] == 'off') {
|
||||||
return parent::beforeDelete($model, $cascade);
|
return parent::beforeDelete($model, $cascade);
|
||||||
|
@ -229,7 +229,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param mixed $model
|
* @param mixed $model
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterDelete($model) {
|
public function afterDelete(Model $model) {
|
||||||
$settings = $this->settings[$model->alias];
|
$settings = $this->settings[$model->alias];
|
||||||
if (!isset($settings['afterDelete']) || $settings['afterDelete'] == 'off') {
|
if (!isset($settings['afterDelete']) || $settings['afterDelete'] == 'off') {
|
||||||
return parent::afterDelete($model);
|
return parent::afterDelete($model);
|
||||||
|
@ -247,7 +247,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param mixed $model
|
* @param mixed $model
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onError($model, $error) {
|
public function onError(Model $model, $error) {
|
||||||
$settings = $this->settings[$model->alias];
|
$settings = $this->settings[$model->alias];
|
||||||
if (!isset($settings['onError']) || $settings['onError'] == 'off') {
|
if (!isset($settings['onError']) || $settings['onError'] == 'off') {
|
||||||
return parent::onError($model, $error);
|
return parent::onError($model, $error);
|
||||||
|
@ -261,7 +261,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
* @param mixed $model
|
* @param mixed $model
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function beforeTest($model) {
|
public function beforeTest(Model $model) {
|
||||||
if (!isset($model->beforeTestResult)) {
|
if (!isset($model->beforeTestResult)) {
|
||||||
$model->beforeTestResult = array();
|
$model->beforeTestResult = array();
|
||||||
}
|
}
|
||||||
|
@ -330,11 +330,11 @@ class TestBehavior extends ModelBehavior {
|
||||||
class Test2Behavior extends TestBehavior {
|
class Test2Behavior extends TestBehavior {
|
||||||
public $mapMethods = array('/mappingRobot(\w+)/' => 'mapped');
|
public $mapMethods = array('/mappingRobot(\w+)/' => 'mapped');
|
||||||
|
|
||||||
public function resolveMethod($model, $stuff) {
|
public function resolveMethod(Model $model, $stuff) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mapped($model, $method, $query) {
|
public function mapped(Model $model, $method, $query) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ class Test3Behavior extends TestBehavior{
|
||||||
* @package Cake.Test.Case.Model
|
* @package Cake.Test.Case.Model
|
||||||
*/
|
*/
|
||||||
class Test4Behavior extends ModelBehavior{
|
class Test4Behavior extends ModelBehavior{
|
||||||
public function setup($model, $config = null) {
|
public function setup(Model $model, $config = null) {
|
||||||
$model->bindModel(
|
$model->bindModel(
|
||||||
array('hasMany' => array('Comment'))
|
array('hasMany' => array('Comment'))
|
||||||
);
|
);
|
||||||
|
@ -366,7 +366,7 @@ class Test4Behavior extends ModelBehavior{
|
||||||
* @package Cake.Test.Case.Model
|
* @package Cake.Test.Case.Model
|
||||||
*/
|
*/
|
||||||
class Test5Behavior extends ModelBehavior{
|
class Test5Behavior extends ModelBehavior{
|
||||||
public function setup($model, $config = null) {
|
public function setup(Model $model, $config = null) {
|
||||||
$model->bindModel(
|
$model->bindModel(
|
||||||
array('belongsTo' => array('User'))
|
array('belongsTo' => array('User'))
|
||||||
);
|
);
|
||||||
|
@ -379,7 +379,7 @@ class Test5Behavior extends ModelBehavior{
|
||||||
* @package Cake.Test.Case.Model
|
* @package Cake.Test.Case.Model
|
||||||
*/
|
*/
|
||||||
class Test6Behavior extends ModelBehavior{
|
class Test6Behavior extends ModelBehavior{
|
||||||
public function setup($model, $config = null) {
|
public function setup(Model $model, $config = null) {
|
||||||
$model->bindModel(
|
$model->bindModel(
|
||||||
array('hasAndBelongsToMany' => array('Tag'))
|
array('hasAndBelongsToMany' => array('Tag'))
|
||||||
);
|
);
|
||||||
|
@ -392,7 +392,7 @@ class Test6Behavior extends ModelBehavior{
|
||||||
* @package Cake.Test.Case.Model
|
* @package Cake.Test.Case.Model
|
||||||
*/
|
*/
|
||||||
class Test7Behavior extends ModelBehavior{
|
class Test7Behavior extends ModelBehavior{
|
||||||
public function setup($model, $config = null) {
|
public function setup(Model $model, $config = null) {
|
||||||
$model->bindModel(
|
$model->bindModel(
|
||||||
array('hasOne' => array('Attachment'))
|
array('hasOne' => array('Attachment'))
|
||||||
);
|
);
|
||||||
|
|
|
@ -1055,7 +1055,7 @@ class MysqlTest extends CakeTestCase {
|
||||||
* @param mixed $model
|
* @param mixed $model
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _buildRelatedModels($model) {
|
protected function _buildRelatedModels(Model $model) {
|
||||||
foreach ($model->associations() as $type) {
|
foreach ($model->associations() as $type) {
|
||||||
foreach ($model->{$type} as $assoc => $assocData) {
|
foreach ($model->{$type} as $assoc => $assocData) {
|
||||||
if (is_string($assocData)) {
|
if (is_string($assocData)) {
|
||||||
|
@ -1077,7 +1077,7 @@ class MysqlTest extends CakeTestCase {
|
||||||
* @param mixed $binding
|
* @param mixed $binding
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function &_prepareAssociationQuery($model, &$queryData, $binding) {
|
protected function &_prepareAssociationQuery(Model $model, &$queryData, $binding) {
|
||||||
$type = $binding['type'];
|
$type = $binding['type'];
|
||||||
$assoc = $binding['model'];
|
$assoc = $binding['model'];
|
||||||
$assocData = $model->{$type}[$assoc];
|
$assocData = $model->{$type}[$assoc];
|
||||||
|
|
Loading…
Reference in a new issue