Skip to content
Permalink
Browse files

Add support libs folder into app and plugins that will allow to split…

… users and vendors code. Libs files should follow cake naming conventions for files names and classes.
  • Loading branch information...
skie committed Oct 21, 2009
1 parent fa6b1b1 commit fb64d14442c9fdeb82fd269d1e6e20e37ea8d403
@@ -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.
*/
@@ -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;
@@ -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'));
@@ -0,0 +1,29 @@
<?php
/* SVN FILE: $Id$ */
/**
* Test Suite TestPlugin Library
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* 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 {}
?>

0 comments on commit fb64d14

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