diff --git a/cake/config/paths.php b/cake/config/paths.php index 4a29fadab45..2ca9ea491b8 100644 --- a/cake/config/paths.php +++ b/cake/config/paths.php @@ -71,6 +71,11 @@ */ define('COMPONENTS', CONTROLLERS.'components'.DS); +/** + * Path to the application's views directory. + */ + define('APPLIBS', APP.'libs'.DS); + /** * Path to the application's views directory. */ diff --git a/cake/libs/configure.php b/cake/libs/configure.php index d75de6b1096..982c48007bf 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -364,7 +364,7 @@ function buildPaths($paths) { * @access private */ function __loadBootstrap($boot) { - $modelPaths = $behaviorPaths = $controllerPaths = $componentPaths = $viewPaths = $helperPaths = $pluginPaths = $vendorPaths = $localePaths = $shellPaths = null; + $libPaths = $modelPaths = $behaviorPaths = $controllerPaths = $componentPaths = $viewPaths = $helperPaths = $pluginPaths = $vendorPaths = $localePaths = $shellPaths = null; if ($boot) { Configure::write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR)); @@ -418,7 +418,7 @@ function __loadBootstrap($boot) { 'models' => $modelPaths, 'views' => $viewPaths, 'controllers' => $controllerPaths, 'helpers' => $helperPaths, 'components' => $componentPaths, 'behaviors' => $behaviorPaths, 'plugins' => $pluginPaths, 'vendors' => $vendorPaths, 'locales' => $localePaths, - 'shells' => $shellPaths + 'shells' => $shellPaths, 'libs' => $libPaths )); } } @@ -448,6 +448,7 @@ class App extends Object { 'behavior' => array('suffix' => '.php', 'extends' => 'ModelBehavior', 'core' => true), 'controller' => array('suffix' => '_controller.php', 'extends' => 'AppController', 'core' => true), 'component' => array('suffix' => '.php', 'extends' => null, 'core' => true), + 'lib' => array('suffix' => '.php', 'extends' => null, 'core' => true), 'view' => array('suffix' => '.php', 'extends' => null, 'core' => true), 'helper' => array('suffix' => '.php', 'extends' => 'AppHelper', 'core' => true), 'vendor' => array('suffix' => '', 'extends' => null, 'core' => true), @@ -487,6 +488,13 @@ class App extends Object { */ var $components = array(); +/** + * List of additional path(s) where libs files reside. + * + * @var array + * @access public + */ + var $libs = array(); /** * List of additional path(s) where view files reside. * @@ -626,6 +634,7 @@ function build($paths = array(), $reset = false) { 'datasources' => array(MODELS . 'datasources'), 'controllers' => array(CONTROLLERS), 'components' => array(COMPONENTS), + 'libs' => array(APPLIBS), 'views' => array(VIEWS), 'helpers' => array(HELPERS), 'locales' => array(APP . 'locale' . DS), @@ -879,7 +888,6 @@ function import($type = null, $name = null, $parent = true, $search = array(), $ $file = Inflector::underscore($name) . ".{$ext}"; } $ext = $_this->__settings($type, $plugin, $parent); - if ($name != null && !class_exists($name . $ext['class'])) { if ($load = $_this->__mapped($name . $ext['class'], $type, $plugin)) { if ($_this->__load($load)) { @@ -1138,6 +1146,12 @@ function __settings($type, $plugin, $parent) { } return array('class' => $type, 'suffix' => null, 'path' => $path); break; + case 'lib': + if ($plugin) { + $path = $pluginPath . DS . 'libs' . DS; + } + return array('class' => null, 'suffix' => null, 'path' => $path); + break; case 'view': if ($plugin) { $path = $pluginPath . DS . 'views' . DS; diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index 0348a42f51f..0ed568226ac 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -502,6 +502,10 @@ function testClassLoading() { $this->assertTrue(class_exists('TestPluginAppController')); $this->assertTrue(class_exists('TestsController')); + $result = App::import('Lib', 'TestPlugin.TestPluginLibrary'); + $this->assertTrue($result); + $this->assertTrue(class_exists('TestPluginLibrary')); + $result = App::import('Helper', 'TestPlugin.OtherHelper'); $this->assertTrue($result); $this->assertTrue(class_exists('OtherHelperHelper')); diff --git a/cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php b/cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php new file mode 100644 index 00000000000..800ec1bf967 --- /dev/null +++ b/cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php @@ -0,0 +1,29 @@ + + * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake + * @subpackage cake.tests.cases.libs + * @since CakePHP(tm) v 1.2.0.5432 + * @version $Rev$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +class TestPluginLibrary {} +?> \ No newline at end of file