Fixing strict errors in translate and acl behaviors.

Removing conditional definition of I18nModel.  There is no reason for it to exist anymore.
Removing duplicate class definition.
This commit is contained in:
mark_story 2010-12-12 17:38:49 -05:00
parent cc81f6d062
commit 48879f8264
3 changed files with 25 additions and 59 deletions

View file

@ -43,7 +43,7 @@ class AclBehavior extends ModelBehavior {
* @param mixed $config
* @return void
*/
public function setup(&$model, $config = array()) {
public function setup($model, $config = array()) {
if (is_string($config)) {
$config = array('type' => $config);
}
@ -67,7 +67,7 @@ class AclBehavior extends ModelBehavior {
* @return array
* @link http://book.cakephp.org/view/1322/node
*/
public function node(&$model, $ref = null) {
public function node($model, $ref = null) {
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
if (empty($ref)) {
$ref = array('model' => $model->name, 'foreign_key' => $model->id);
@ -81,7 +81,7 @@ class AclBehavior extends ModelBehavior {
* @param boolean $created True if this is a new record
* @return void
*/
public function afterSave(&$model, $created) {
public function afterSave($model, $created) {
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
$parent = $model->parentNode();
if (!empty($parent)) {
@ -105,7 +105,7 @@ class AclBehavior extends ModelBehavior {
*
* @return void
*/
public function afterDelete(&$model) {
public function afterDelete($model) {
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
$node = Set::extract($this->node($model), "0.{$type}.id");
if (!empty($node)) {

View file

@ -51,7 +51,7 @@ class TranslateBehavior extends ModelBehavior {
* @param array $config Array of configuration information.
* @return mixed
*/
public function setup(&$model, $config = array()) {
public function setup($model, $config = array()) {
$db = ConnectionManager::getDataSource($model->useDbConfig);
if (!$db->connected) {
trigger_error(
@ -73,7 +73,7 @@ class TranslateBehavior extends ModelBehavior {
* @param Model $model Model being detached.
* @return void
*/
public function cleanup(&$model) {
public function cleanup($model) {
$this->unbindTranslation($model);
unset($this->settings[$model->alias]);
unset($this->runtime[$model->alias]);
@ -86,7 +86,7 @@ class TranslateBehavior extends ModelBehavior {
* @param array $query Array of Query parameters.
* @return array Modified query
*/
public function beforeFind(&$model, $query) {
public function beforeFind($model, $query) {
$this->runtime[$model->alias]['virtualFields'] = $model->virtualFields;
$locale = $this->_getLocale($model);
if (empty($locale)) {
@ -196,7 +196,7 @@ class TranslateBehavior extends ModelBehavior {
* @param boolean $primary Did the find originate on $model.
* @return array Modified results
*/
public function afterFind(&$model, $results, $primary) {
public function afterFind($model, $results, $primary) {
$model->virtualFields = $this->runtime[$model->alias]['virtualFields'];
$this->runtime[$model->alias]['virtualFields'] = $this->runtime[$model->alias]['fields'] = array();
$locale = $this->_getLocale($model);
@ -242,7 +242,7 @@ class TranslateBehavior extends ModelBehavior {
* @param Model $model Model invalidFields was called on.
* @return boolean
*/
public function beforeValidate(&$model) {
public function beforeValidate($model) {
$locale = $this->_getLocale($model);
if (empty($locale)) {
return true;
@ -276,7 +276,7 @@ class TranslateBehavior extends ModelBehavior {
* @param boolean $created Whether or not the save created a record.
* @return void
*/
public function afterSave(&$model, $created) {
public function afterSave($model, $created) {
if (!isset($this->runtime[$model->alias]['beforeSave'])) {
return true;
}
@ -284,7 +284,7 @@ class TranslateBehavior extends ModelBehavior {
$tempData = $this->runtime[$model->alias]['beforeSave'];
unset($this->runtime[$model->alias]['beforeSave']);
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
$RuntimeModel =& $this->translateModel($model);
$RuntimeModel = $this->translateModel($model);
foreach ($tempData as $field => $value) {
unset($conditions['content']);
@ -319,8 +319,8 @@ class TranslateBehavior extends ModelBehavior {
* @param Model $model Model the callback was run on.
* @return void
*/
public function afterDelete(&$model) {
$RuntimeModel =& $this->translateModel($model);
public function afterDelete($model) {
$RuntimeModel = $this->translateModel($model);
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
$RuntimeModel->deleteAll($conditions);
}
@ -331,12 +331,12 @@ class TranslateBehavior extends ModelBehavior {
* @param Model $model Model the locale needs to be set/get on.
* @return mixed string or false
*/
protected function _getLocale(&$model) {
protected function _getLocale($model) {
if (!isset($model->locale) || is_null($model->locale)) {
if (!class_exists('I18n')) {
App::import('Core', 'i18n');
}
$I18n =& I18n::getInstance();
$I18n = I18n::getInstance();
$I18n->l10n->get(Configure::read('Config.language'));
$model->locale = $I18n->l10n->locale;
}
@ -353,7 +353,7 @@ class TranslateBehavior extends ModelBehavior {
* @param Model $model Model to get a translatemodel for.
* @return object
*/
public function &translateModel(&$model) {
public function translateModel($model) {
if (!isset($this->runtime[$model->alias]['model'])) {
if (!isset($model->translateModel) || empty($model->translateModel)) {
$className = 'I18nModel';
@ -380,12 +380,12 @@ class TranslateBehavior extends ModelBehavior {
* @param boolean $reset
* @return bool
*/
function bindTranslation(&$model, $fields, $reset = true) {
function bindTranslation($model, $fields, $reset = true) {
if (is_string($fields)) {
$fields = array($fields);
}
$associations = array();
$RuntimeModel =& $this->translateModel($model);
$RuntimeModel = $this->translateModel($model);
$default = array('className' => $RuntimeModel->alias, 'foreignKey' => 'foreign_key');
foreach ($fields as $key => $value) {
@ -453,7 +453,7 @@ class TranslateBehavior extends ModelBehavior {
* unbind all original translations
* @return bool
*/
function unbindTranslation(&$model, $fields = null) {
function unbindTranslation($model, $fields = null) {
if (empty($fields) && empty($this->settings[$model->alias])) {
return false;
}
@ -464,7 +464,7 @@ class TranslateBehavior extends ModelBehavior {
if (is_string($fields)) {
$fields = array($fields);
}
$RuntimeModel =& $this->translateModel($model);
$RuntimeModel = $this->translateModel($model);
$associations = array();
foreach ($fields as $key => $value) {
@ -499,15 +499,13 @@ class TranslateBehavior extends ModelBehavior {
return true;
}
}
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
/**
* @package cake
* @subpackage cake.cake.libs.model.behaviors
*/
class I18nModel extends AppModel {
class I18nModel extends AppModel {
public $name = 'I18nModel';
public $useTable = 'i18n';
public $displayField = 'field';
}
}

View file

@ -2591,38 +2591,6 @@ class MyCategoriesMyProduct extends CakeTestModel {
public $name = 'MyCategoriesMyProduct';
}
/**
* I18nModel class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class I18nModel extends CakeTestModel {
/**
* name property
*
* @var string 'I18nModel'
* @access public
*/
public $name = 'I18nModel';
/**
* useTable property
*
* @var string 'i18n'
* @access public
*/
public $useTable = 'i18n';
/**
* displayField property
*
* @var string 'field'
* @access public
*/
public $displayField = 'field';
}
/**
* NumberTree class
@ -2662,7 +2630,7 @@ class NumberTree extends CakeTestModel {
*/
function initialize($levelLimit = 3, $childLimit = 3, $currentLevel = null, $parent_id = null, $prefix = '1', $hierachial = true) {
if (!$parent_id) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$db = ConnectionManager::getDataSource($this->useDbConfig);
$db->truncate($this->table);
$this->save(array($this->name => array('name' => '1. Root')));
$this->initialize($levelLimit, $childLimit, 1, $this->id, '1', $hierachial);