Skip to content
Permalink
Browse files

Adding App::themePath(). Will be used to reduce code duplication in a…

… variety of places.
  • Loading branch information...
markstory committed Jul 1, 2010
1 parent e023350 commit 91f8e220e49889a82632d39f32a681b67cc5d6ad
Showing with 38 additions and 1 deletion.
  1. +18 −1 cake/libs/configure.php
  2. +20 −0 cake/tests/cases/libs/configure.test.php
@@ -702,7 +702,7 @@ function build($paths = array(), $reset = false) {
/**
* Get the path that a plugin is on. Searches through the defined plugin paths.
*
* @param string $plugin CamelCased plugin name to find the path of.
* @param string $plugin CamelCased/lower_cased plugin name to find the path of.
* @return string full path to the plugin.
*/
function pluginPath($plugin) {
@@ -716,6 +716,23 @@ function pluginPath($plugin) {
return $_this->plugins[0] . $pluginDir . DS;
}
/**
* Find the path that a theme is on. Search through the defined theme paths.
*
* @param string $theme lower_cased theme name to find the path of.
* @return string full path to the theme.
*/
function themePath($theme) {
$_this =& App::getInstance();
$themeDir = 'themed' . DS . Inflector::underscore($theme);
for ($i = 0, $length = count($_this->views); $i < $length; $i++) {
if (is_dir($_this->views[$i] . $themeDir)) {
return $_this->views[$i] . $themeDir . DS ;
}
}
return $_this->views[0] . $themeDir . DS;
}
/**
* Returns a key/value list of all paths where core libs are found.
* Passing $type only returns the values for a given value of $key.
@@ -460,6 +460,26 @@ function testPluginPath() {
App::build();
}
/**
* test that pluginPath can find paths for plugins.
*
* @return void
*/
function testThemePath() {
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)
));
$path = App::themePath('test_theme');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
$this->assertEqual($path, $expected);
$path = App::themePath('TestTheme');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
$this->assertEqual($path, $expected);
App::build();
}
/**
* testClassLoading method
*

0 comments on commit 91f8e22

Please sign in to comment.
You can’t perform that action at this time.