File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -702,7 +702,7 @@ function build($paths = array(), $reset = false) {
702
702
/**
703
703
* Get the path that a plugin is on. Searches through the defined plugin paths.
704
704
*
705
- * @param string $plugin CamelCased plugin name to find the path of.
705
+ * @param string $plugin CamelCased/lower_cased plugin name to find the path of.
706
706
* @return string full path to the plugin.
707
707
*/
708
708
function pluginPath ($ plugin ) {
@@ -716,6 +716,23 @@ function pluginPath($plugin) {
716
716
return $ _this ->plugins [0 ] . $ pluginDir . DS ;
717
717
}
718
718
719
+ /**
720
+ * Find the path that a theme is on. Search through the defined theme paths.
721
+ *
722
+ * @param string $theme lower_cased theme name to find the path of.
723
+ * @return string full path to the theme.
724
+ */
725
+ function themePath ($ theme ) {
726
+ $ _this =& App::getInstance ();
727
+ $ themeDir = 'themed ' . DS . Inflector::underscore ($ theme );
728
+ for ($ i = 0 , $ length = count ($ _this ->views ); $ i < $ length ; $ i ++) {
729
+ if (is_dir ($ _this ->views [$ i ] . $ themeDir )) {
730
+ return $ _this ->views [$ i ] . $ themeDir . DS ;
731
+ }
732
+ }
733
+ return $ _this ->views [0 ] . $ themeDir . DS ;
734
+ }
735
+
719
736
/**
720
737
* Returns a key/value list of all paths where core libs are found.
721
738
* Passing $type only returns the values for a given value of $key.
Original file line number Diff line number Diff line change @@ -460,6 +460,26 @@ function testPluginPath() {
460
460
App::build ();
461
461
}
462
462
463
+ /**
464
+ * test that pluginPath can find paths for plugins.
465
+ *
466
+ * @return void
467
+ */
468
+ function testThemePath () {
469
+ App::build (array (
470
+ 'views ' => array (TEST_CAKE_CORE_INCLUDE_PATH . 'tests ' . DS . 'test_app ' . DS . 'views ' . DS )
471
+ ));
472
+ $ path = App::themePath ('test_theme ' );
473
+ $ expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests ' . DS . 'test_app ' . DS . 'views ' . DS . 'themed ' . DS . 'test_theme ' . DS ;
474
+ $ this ->assertEqual ($ path , $ expected );
475
+
476
+ $ path = App::themePath ('TestTheme ' );
477
+ $ expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests ' . DS . 'test_app ' . DS . 'views ' . DS . 'themed ' . DS . 'test_theme ' . DS ;
478
+ $ this ->assertEqual ($ path , $ expected );
479
+
480
+ App::build ();
481
+ }
482
+
463
483
/**
464
484
* testClassLoading method
465
485
*
You can’t perform that action at this time.
0 commit comments