mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #9086 from psaintjust/association-plugin-classname
Association plugin classname
This commit is contained in:
commit
7763e5d6bc
3 changed files with 13 additions and 8 deletions
|
@ -1035,13 +1035,13 @@ class Model extends Object implements CakeEventListener {
|
||||||
unset($association[$assoc]);
|
unset($association[$assoc]);
|
||||||
$assoc = $value;
|
$assoc = $value;
|
||||||
$value = array();
|
$value = array();
|
||||||
|
|
||||||
if (strpos($assoc, '.') !== false) {
|
|
||||||
list($plugin, $assoc) = pluginSplit($assoc, true);
|
|
||||||
$association[$assoc] = array('className' => $plugin . $assoc);
|
|
||||||
} else {
|
|
||||||
$association[$assoc] = $value;
|
$association[$assoc] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($value['className']) && strpos($assoc, '.') !== false) {
|
||||||
|
unset($association[$assoc]);
|
||||||
|
list($plugin, $assoc) = pluginSplit($assoc, true);
|
||||||
|
$association[$assoc] = array('className' => $plugin . $assoc) + $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_generateAssociation($type, $assoc);
|
$this->_generateAssociation($type, $assoc);
|
||||||
|
|
|
@ -1617,10 +1617,12 @@ class ModelIntegrationTest extends BaseModelTest {
|
||||||
public function testAutoConstructPluginAssociations() {
|
public function testAutoConstructPluginAssociations() {
|
||||||
$Comment = ClassRegistry::init('TestPluginComment');
|
$Comment = ClassRegistry::init('TestPluginComment');
|
||||||
|
|
||||||
$this->assertEquals(2, count($Comment->belongsTo), 'Too many associations');
|
$this->assertEquals(3, count($Comment->belongsTo), 'Too many associations');
|
||||||
$this->assertFalse(isset($Comment->belongsTo['TestPlugin.User']));
|
$this->assertFalse(isset($Comment->belongsTo['TestPlugin.User']));
|
||||||
|
$this->assertFalse(isset($Comment->belongsTo['TestPlugin.Source']));
|
||||||
$this->assertTrue(isset($Comment->belongsTo['User']), 'Missing association');
|
$this->assertTrue(isset($Comment->belongsTo['User']), 'Missing association');
|
||||||
$this->assertTrue(isset($Comment->belongsTo['TestPluginArticle']), 'Missing association');
|
$this->assertTrue(isset($Comment->belongsTo['TestPluginArticle']), 'Missing association');
|
||||||
|
$this->assertTrue(isset($Comment->belongsTo['Source']), 'Missing association');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2991,7 +2991,10 @@ class TestPluginComment extends CakeTestModel {
|
||||||
'className' => 'TestPlugin.TestPluginArticle',
|
'className' => 'TestPlugin.TestPluginArticle',
|
||||||
'foreignKey' => 'article_id',
|
'foreignKey' => 'article_id',
|
||||||
),
|
),
|
||||||
'TestPlugin.User'
|
'TestPlugin.User',
|
||||||
|
'TestPlugin.Source' => array(
|
||||||
|
'foreignKey' => 'source_id'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue