mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fixes #4432, Model aliases. Updated cases. Removed usage of $this->model in model.test.php in favor of local variables
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6848 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ead3ff125d
commit
c0f042e4ab
3 changed files with 737 additions and 712 deletions
|
@ -314,26 +314,24 @@ class Model extends Overloadable {
|
|||
function __construct($id = false, $table = null, $ds = null) {
|
||||
parent::__construct();
|
||||
|
||||
if (is_array($id) && isset($id['name'])) {
|
||||
$options = array_merge(array('id' => false, 'table' => null, 'ds' => null, 'alias' => null), $id);
|
||||
list($id, $table, $ds) = array($options['id'], $options['table'], $options['ds']);
|
||||
$this->name = $options['name'];
|
||||
if (is_array($id)) {
|
||||
extract(array_merge(array('id' => false, 'table' => null, 'ds' => null, 'name' => null, 'alias' => null), $id));
|
||||
$this->name = $name;
|
||||
$this->alias = $alias;
|
||||
}
|
||||
|
||||
if ($this->name === null) {
|
||||
$this->name = get_class($this);
|
||||
}
|
||||
|
||||
if ($this->alias === null) {
|
||||
$this->alias = $this->name;
|
||||
}
|
||||
|
||||
if ($this->primaryKey === null) {
|
||||
$this->primaryKey = 'id';
|
||||
}
|
||||
|
||||
if (isset($options['alias']) || !empty($options['alias'])) {
|
||||
$this->alias = $options['alias'];
|
||||
unset($options);
|
||||
} else {
|
||||
$this->alias = $this->name;
|
||||
}
|
||||
ClassRegistry::addObject($this->alias, $this);
|
||||
|
||||
$this->id = $id;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -50,6 +50,26 @@ class Test extends Model {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class TestAlias extends Model {
|
||||
var $useTable = false;
|
||||
var $name = 'TestAlias';
|
||||
var $alias = 'TestAlias';
|
||||
var $_schema = array(
|
||||
'id'=> array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key'=>'primary'),
|
||||
'name'=> array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
|
||||
'email'=> array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
||||
'notes'=> array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''),
|
||||
'created'=> array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
|
||||
'updated'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue