mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-04-01 06:32:57 +00:00
fixes #5331, model alias no longer overwritten
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7515 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
7e039ee62d
commit
7fe1a03fda
2 changed files with 50 additions and 5 deletions
cake
|
@ -318,17 +318,23 @@ class Model extends Overloadable {
|
||||||
extract(array_merge(
|
extract(array_merge(
|
||||||
array('id' => $this->id, 'table' => $this->useTable, 'ds' => $this->useDbConfig, 'name' => $this->name, 'alias' => $this->alias),
|
array('id' => $this->id, 'table' => $this->useTable, 'ds' => $this->useDbConfig, 'name' => $this->name, 'alias' => $this->alias),
|
||||||
$id));
|
$id));
|
||||||
$this->name = $name;
|
|
||||||
$this->alias = $alias;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->name === null) {
|
if ($this->name === null) {
|
||||||
|
if (isset($name)) {
|
||||||
|
$this->name = $name;
|
||||||
|
} else {
|
||||||
$this->name = get_class($this);
|
$this->name = get_class($this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->alias === null) {
|
if ($this->alias === null) {
|
||||||
|
if (isset($alias)) {
|
||||||
|
$this->alias = $alias;
|
||||||
|
} else {
|
||||||
$this->alias = $this->name;
|
$this->alias = $this->name;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->primaryKey === null) {
|
if ($this->primaryKey === null) {
|
||||||
$this->primaryKey = 'id';
|
$this->primaryKey = 'id';
|
||||||
|
|
|
@ -127,6 +127,33 @@ class ControllerComment extends CakeTestModel {
|
||||||
*/
|
*/
|
||||||
var $alias = 'ControllerComment';
|
var $alias = 'ControllerComment';
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* NameTest class
|
||||||
|
*
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.cases.libs.controller
|
||||||
|
*/
|
||||||
|
class NameTest extends CakeTestModel {
|
||||||
|
/**
|
||||||
|
* name property
|
||||||
|
* @var string 'Name'
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $name = 'Name';
|
||||||
|
/**
|
||||||
|
* useTable property
|
||||||
|
* @var string 'names'
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $useTable = 'comments';
|
||||||
|
/**
|
||||||
|
* alias property
|
||||||
|
*
|
||||||
|
* @var string 'ControllerComment'
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $alias = 'Name';
|
||||||
|
}
|
||||||
if (!class_exists('AppController')) {
|
if (!class_exists('AppController')) {
|
||||||
/**
|
/**
|
||||||
* AppController class
|
* AppController class
|
||||||
|
@ -231,7 +258,7 @@ class ControllerTest extends CakeTestCase {
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $fixtures = array('core.post', 'core.comment');
|
var $fixtures = array('core.post', 'core.comment', 'core.name');
|
||||||
/**
|
/**
|
||||||
* testConstructClasses method
|
* testConstructClasses method
|
||||||
*
|
*
|
||||||
|
@ -258,6 +285,18 @@ class ControllerTest extends CakeTestCase {
|
||||||
|
|
||||||
unset($Controller);
|
unset($Controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testAliasName() {
|
||||||
|
$Controller =& new Controller();
|
||||||
|
$Controller->uses = array('NameTest');
|
||||||
|
$Controller->constructClasses();
|
||||||
|
|
||||||
|
$this->assertEqual($Controller->NameTest->name, 'Name');
|
||||||
|
$this->assertEqual($Controller->NameTest->alias, 'Name');
|
||||||
|
|
||||||
|
unset($Controller);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testPersistent method
|
* testPersistent method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue