mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Reversed alias and actual class to be more consistent with how Model aliases load and to make migration easier
This commit is contained in:
parent
24d90c17d6
commit
2b596859cb
6 changed files with 11 additions and 10 deletions
|
@ -76,8 +76,8 @@ class ComponentCollection extends ObjectCollection {
|
|||
public function load($component, $settings = array()) {
|
||||
list($plugin, $name) = pluginSplit($component);
|
||||
$alias = $name;
|
||||
if (isset($settings['alias'])) {
|
||||
$alias = $settings['alias'];
|
||||
if (isset($settings['className'])) {
|
||||
$name = $settings['className'];
|
||||
}
|
||||
if (isset($this->_loaded[$alias])) {
|
||||
return $this->_loaded[$alias];
|
||||
|
|
|
@ -100,11 +100,12 @@ class BehaviorCollection extends ObjectCollection {
|
|||
*/
|
||||
public function load($behavior, $config = array()) {
|
||||
list($plugin, $name) = pluginSplit($behavior);
|
||||
$class = $name . 'Behavior';
|
||||
|
||||
$alias = $name;
|
||||
if (isset($config['alias'])) {
|
||||
$alias = $config['alias'];
|
||||
if (isset($config['className'])) {
|
||||
$name = $config['className'];
|
||||
}
|
||||
$class = $name . 'Behavior';
|
||||
|
||||
if (!App::import('Behavior', $behavior)) {
|
||||
throw new MissingBehaviorFileException(array(
|
||||
|
|
|
@ -60,8 +60,8 @@ class HelperCollection extends ObjectCollection {
|
|||
list($plugin, $name) = pluginSplit($helper, true);
|
||||
|
||||
$alias = $name;
|
||||
if (isset($settings['alias'])) {
|
||||
$alias = $settings['alias'];
|
||||
if (isset($settings['className'])) {
|
||||
$name = $settings['className'];
|
||||
}
|
||||
|
||||
if (isset($this->_loaded[$alias])) {
|
||||
|
|
|
@ -70,7 +70,7 @@ class ComponentCollectionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testLoadWithAlias() {
|
||||
$result = $this->Components->load('CookieAlias', array('alias' => 'Cookie', 'somesetting' => true));
|
||||
$result = $this->Components->load('Cookie', array('className' => 'CookieAlias', 'somesetting' => true));
|
||||
$this->assertInstanceOf('CookieAliasComponent', $result);
|
||||
$this->assertInstanceOf('CookieAliasComponent', $this->Components->Cookie);
|
||||
$this->assertTrue($this->Components->Cookie->settings['somesetting']);
|
||||
|
|
|
@ -443,7 +443,7 @@ class BehaviorCollectionTest extends CakeTestCase {
|
|||
$Apple = new Apple();
|
||||
$this->assertIdentical($Apple->Behaviors->attached(), array());
|
||||
|
||||
$Apple->Behaviors->load('TestAlias', array('alias' => 'Test', 'somesetting' => true));
|
||||
$Apple->Behaviors->load('Test', array('className' => 'TestAlias', 'somesetting' => true));
|
||||
$this->assertIdentical($Apple->Behaviors->attached(), array('Test'));
|
||||
$this->assertInstanceOf('TestAliasBehavior', $Apple->Behaviors->Test);
|
||||
$this->assertTrue($Apple->Behaviors->Test->settings['Apple']['somesetting']);
|
||||
|
|
|
@ -69,7 +69,7 @@ class HelperCollectionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testLoadWithAlias() {
|
||||
$result = $this->Helpers->load('HtmlAlias', array('alias' => 'Html'));
|
||||
$result = $this->Helpers->load('Html', array('className' => 'HtmlAlias'));
|
||||
$this->assertInstanceOf('HtmlAliasHelper', $result);
|
||||
$this->assertInstanceOf('HtmlAliasHelper', $this->Helpers->Html);
|
||||
|
||||
|
|
Loading…
Reference in a new issue