mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
This commit is contained in:
parent
8f2a4a1e0e
commit
cb4a1f07e5
7 changed files with 83 additions and 7 deletions
|
@ -667,6 +667,9 @@ class Model extends Overloadable {
|
||||||
} else {
|
} else {
|
||||||
$this->{$assoc} =& ClassRegistry::init($model);
|
$this->{$assoc} =& ClassRegistry::init($model);
|
||||||
}
|
}
|
||||||
|
if (strpos($className, '.') !== false) {
|
||||||
|
ClassRegistry::addObject($className, $this->{$assoc});
|
||||||
|
}
|
||||||
if ($assoc) {
|
if ($assoc) {
|
||||||
$this->tableToModel[$this->{$assoc}->table] = $assoc;
|
$this->tableToModel[$this->{$assoc}->table] = $assoc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ class Object {
|
||||||
if (strpos($key, '_behavior') !== false) {
|
if (strpos($key, '_behavior') !== false) {
|
||||||
App::import('Behavior', Inflector::classify(substr($key, 0, -9)));
|
App::import('Behavior', Inflector::classify(substr($key, 0, -9)));
|
||||||
} else {
|
} else {
|
||||||
App::import('Model', Inflector::classify($key));
|
App::import('Model', Inflector::camelize($key));
|
||||||
}
|
}
|
||||||
unset ($value);
|
unset ($value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,6 +431,7 @@ class ObjectTest extends CakeTestCase {
|
||||||
$this->assertFalse(class_exists('PersisterOneBehaviorBehavior'));
|
$this->assertFalse(class_exists('PersisterOneBehaviorBehavior'));
|
||||||
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
|
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
|
||||||
$this->assertFalse(class_exists('TestPluginPersisterBehavior'));
|
$this->assertFalse(class_exists('TestPluginPersisterBehavior'));
|
||||||
|
$this->assertFalse(class_exists('TestPluginAuthors'));
|
||||||
|
|
||||||
$Controller = new RequestActionPersistentController();
|
$Controller = new RequestActionPersistentController();
|
||||||
$Controller->persistModel = true;
|
$Controller->persistModel = true;
|
||||||
|
@ -439,13 +440,18 @@ class ObjectTest extends CakeTestCase {
|
||||||
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisterone.php'));
|
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisterone.php'));
|
||||||
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
|
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
|
||||||
|
|
||||||
$contents = str_replace('"PersisterOne"', '"PersisterTwo"', file_get_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
|
$contents = file_get_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
|
||||||
$contents = str_replace('persister_one_', 'persister_two_', file_get_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
|
$contents = str_replace('"PersisterOne"', '"PersisterTwo"', $contents);
|
||||||
|
$contents = str_replace('persister_one', 'persister_two', $contents);
|
||||||
|
$contents = str_replace('test_plugin_comment', 'test_plugin_authors', $contents);
|
||||||
$result = file_put_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php', $contents);
|
$result = file_put_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php', $contents);
|
||||||
|
|
||||||
$this->assertTrue(class_exists('PersisterOneBehaviorBehavior'));
|
$this->assertTrue(class_exists('PersisterOneBehaviorBehavior'));
|
||||||
|
$this->assertTrue(class_exists('TestPluginPersisterOneBehavior'));
|
||||||
|
$this->assertTrue(class_exists('TestPluginComment'));
|
||||||
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
|
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
|
||||||
$this->assertFalse(class_exists('TestPluginPersisterTwoBehavior'));
|
$this->assertFalse(class_exists('TestPluginPersisterTwoBehavior'));
|
||||||
|
$this->assertFalse(class_exists('TestPluginAuthors'));
|
||||||
|
|
||||||
$Controller = new RequestActionPersistentController();
|
$Controller = new RequestActionPersistentController();
|
||||||
$Controller->persistModel = true;
|
$Controller->persistModel = true;
|
||||||
|
@ -454,6 +460,7 @@ class ObjectTest extends CakeTestCase {
|
||||||
$this->assertTrue(class_exists('PersisterOneBehaviorBehavior'));
|
$this->assertTrue(class_exists('PersisterOneBehaviorBehavior'));
|
||||||
$this->assertTrue(class_exists('PersisterTwoBehaviorBehavior'));
|
$this->assertTrue(class_exists('PersisterTwoBehaviorBehavior'));
|
||||||
$this->assertTrue(class_exists('TestPluginPersisterTwoBehavior'));
|
$this->assertTrue(class_exists('TestPluginPersisterTwoBehavior'));
|
||||||
|
$this->assertTrue(class_exists('TestPluginAuthors'));
|
||||||
|
|
||||||
@unlink(CACHE . 'persistent' . DS . 'persisterone.php');
|
@unlink(CACHE . 'persistent' . DS . 'persisterone.php');
|
||||||
@unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
|
@unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
|
||||||
|
@ -490,6 +497,8 @@ class ObjectTest extends CakeTestCase {
|
||||||
$this->assertEqual($keys, array(
|
$this->assertEqual($keys, array(
|
||||||
'persister_one',
|
'persister_one',
|
||||||
'comment',
|
'comment',
|
||||||
|
'test_plugin_comment',
|
||||||
|
'test_plugin.test_plugin_comment',
|
||||||
'persister_one_behavior_behavior',
|
'persister_one_behavior_behavior',
|
||||||
'test_plugin_persister_one_behavior',
|
'test_plugin_persister_one_behavior',
|
||||||
'test_plugin.test_plugin_persister_one_behavior'
|
'test_plugin.test_plugin_persister_one_behavior'
|
||||||
|
@ -504,6 +513,8 @@ class ObjectTest extends CakeTestCase {
|
||||||
$this->assertEqual($keys, array(
|
$this->assertEqual($keys, array(
|
||||||
'persister_one',
|
'persister_one',
|
||||||
'comment',
|
'comment',
|
||||||
|
'test_plugin_comment',
|
||||||
|
'test_plugin.test_plugin_comment',
|
||||||
'persister_one_behavior_behavior',
|
'persister_one_behavior_behavior',
|
||||||
'test_plugin_persister_one_behavior',
|
'test_plugin_persister_one_behavior',
|
||||||
'test_plugin.test_plugin_persister_one_behavior',
|
'test_plugin.test_plugin_persister_one_behavior',
|
||||||
|
|
|
@ -28,8 +28,8 @@ class PersisterOne extends AppModel {
|
||||||
var $useTable = 'posts';
|
var $useTable = 'posts';
|
||||||
var $name = 'PersisterOne';
|
var $name = 'PersisterOne';
|
||||||
|
|
||||||
var $actsAs = array('PersisterOneBehavior','TestPlugin.TestPluginPersisterOne');
|
var $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
|
||||||
|
|
||||||
var $hasMany = array('Comment');
|
var $hasMany = array('Comment', 'TestPlugin.TestPluginComment');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -28,8 +28,8 @@ class PersisterTwo extends AppModel {
|
||||||
var $useTable = 'posts';
|
var $useTable = 'posts';
|
||||||
var $name = 'PersisterTwo';
|
var $name = 'PersisterTwo';
|
||||||
|
|
||||||
var $actsAs = array('PersisterOneBehavior','TestPlugin.TestPluginPersisterOne');
|
var $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
|
||||||
|
|
||||||
var $hasMany = array('Comment');
|
var $hasMany = array('Comment', 'TestPlugin.TestPluginComment');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* Test App Comment Model
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP : Rapid Development Framework (http://www.cakephp.org)
|
||||||
|
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.cake.libs.
|
||||||
|
* @since CakePHP v 1.2.0.7726
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
class TestPluginAuthors extends TestPluginAppModel {
|
||||||
|
var $useTable = 'authors';
|
||||||
|
var $name = 'TestPluginAuthors';
|
||||||
|
}
|
||||||
|
?>
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* Test App Comment Model
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP : Rapid Development Framework (http://www.cakephp.org)
|
||||||
|
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.cake.libs.
|
||||||
|
* @since CakePHP v 1.2.0.7726
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
class TestPluginComment extends TestPluginAppModel {
|
||||||
|
var $useTable = 'comments';
|
||||||
|
var $name = 'TestPluginComment';
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in a new issue