diff --git a/cake/basics.php b/cake/basics.php index 039d1c42e..516fe746b 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -220,9 +220,10 @@ if (!function_exists('array_combine')) { * * @param string $name The name you want to plugin split. * @param boolean $dotAppend Set to true if you want the plugin to have a '.' appended to it. + * @param string $plugin Optional default plugin to use if no plugin is found. Defaults to null. * @return array Array with 2 indexes. 0 => plugin name, 1 => classname */ - function pluginSplit($name, $dotAppend = false) { + function pluginSplit($name, $dotAppend = false, $plugin = null) { if (strpos($name, '.') !== false) { $parts = explode('.', $name, 2); if ($dotAppend) { @@ -230,7 +231,7 @@ if (!function_exists('array_combine')) { } return $parts; } - return array(null, $name); + return array($plugin, $name); } /** diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php index ff39e9fa1..bb24c70f9 100644 --- a/cake/tests/cases/basics.test.php +++ b/cake/tests/cases/basics.test.php @@ -773,18 +773,24 @@ class BasicsTest extends CakeTestCase { function testPluginSplit() { $result = pluginSplit('Something.else'); $this->assertEqual($result, array('Something', 'else')); - + $result = pluginSplit('Something.else.more.dots'); $this->assertEqual($result, array('Something', 'else.more.dots')); $result = pluginSplit('Somethingelse'); $this->assertEqual($result, array(null, 'Somethingelse')); - + $result = pluginSplit('Something.else', true); $this->assertEqual($result, array('Something.', 'else')); - + $result = pluginSplit('Something.else.more.dots', true); $this->assertEqual($result, array('Something.', 'else.more.dots')); + + $result = pluginSplit('Post', false, 'Blog'); + $this->assertEqual($result, array('Blog', 'Post')); + + $result = pluginSplit('Blog.Post', false, 'Ultimate'); + $this->assertEqual($result, array('Blog', 'Post')); } } ?> \ No newline at end of file