Starting code changes to allow dot notation for loading of all classes

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5197 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-05-26 09:50:17 +00:00
parent 83f0635b3b
commit 459cb5c45a

View file

@ -84,6 +84,7 @@
* *
* @param string $plugin Name of plugin * @param string $plugin Name of plugin
* @return * @return
* @deprecated
*/ */
function loadPluginModels($plugin) { function loadPluginModels($plugin) {
if(!class_exists('AppModel')){ if(!class_exists('AppModel')){
@ -117,6 +118,10 @@
* *
*/ */
function loadView($viewClass) { function loadView($viewClass) {
if(strpos($viewClass, '.') !== false){
list($plugin, $viewClass) = explode('.', $viewClass);
}
if (!class_exists($viewClass . 'View')) { if (!class_exists($viewClass . 'View')) {
$paths = Configure::getInstance(); $paths = Configure::getInstance();
$file = Inflector::underscore($viewClass) . '.php'; $file = Inflector::underscore($viewClass) . '.php';
@ -136,6 +141,7 @@
} }
} }
} }
return true;
} }
/** /**
* Loads a model by CamelCase name. * Loads a model by CamelCase name.
@ -183,9 +189,8 @@
} }
} }
return false; return false;
} else {
return true;
} }
return true;
} }
function paths(){ function paths(){
@ -308,9 +313,8 @@
return false; return false;
} }
} }
} else {
return false;
} }
return false;
} }
/** /**
* Loads a plugin's controller. * Loads a plugin's controller.
@ -318,6 +322,7 @@
* @param string $plugin Name of plugin * @param string $plugin Name of plugin
* @param string $controller Name of controller to load * @param string $controller Name of controller to load
* @return boolean Success * @return boolean Success
* @deprecated
*/ */
function loadPluginController($plugin, $controller) { function loadPluginController($plugin, $controller) {
$pluginAppController = Inflector::camelize($plugin . '_app_controller'); $pluginAppController = Inflector::camelize($plugin . '_app_controller');
@ -413,9 +418,8 @@
return false; return false;
} }
} }
} else {
return true;
} }
return true;
} }
/** /**
* Loads a plugin's helper * Loads a plugin's helper
@ -423,6 +427,7 @@
* @param string $plugin Name of plugin * @param string $plugin Name of plugin
* @param string $helper Name of helper to load * @param string $helper Name of helper to load
* @return boolean Success * @return boolean Success
* @deprecated
*/ */
function loadPluginHelper($plugin, $helper) { function loadPluginHelper($plugin, $helper) {
loadHelper(null); loadHelper(null);
@ -436,9 +441,8 @@
} else { } else {
return false; return false;
} }
} else {
return true;
} }
return true;
} }
/** /**
* Loads a component * Loads a component
@ -447,10 +451,10 @@
* @return boolean Success * @return boolean Success
*/ */
function loadComponent($name) { function loadComponent($name) {
if ($name === null) { if ($name === null) {
return true; return true;
} }
if(strpos($name, '.') !== false){ if(strpos($name, '.') !== false){
list($plugin, $name) = explode('.', $name); list($plugin, $name) = explode('.', $name);
} }
@ -469,8 +473,8 @@
return true; return true;
} }
} }
$paths = Configure::getInstance(); $paths = Configure::getInstance();
foreach($paths->componentPaths as $path) { foreach($paths->componentPaths as $path) {
if (file_exists($path . $name . '.php')) { if (file_exists($path . $name . '.php')) {
Configure::store('Components', 'class.paths', array($className => array('path' => $path . $name . '.php'))); Configure::store('Components', 'class.paths', array($className => array('path' => $path . $name . '.php')));
@ -488,9 +492,8 @@
return false; return false;
} }
} }
} else {
return true;
} }
return true;
} }
/** /**
* Loads a plugin's component * Loads a plugin's component
@ -498,6 +501,7 @@
* @param string $plugin Name of plugin * @param string $plugin Name of plugin
* @param string $helper Name of component to load * @param string $helper Name of component to load
* @return boolean Success * @return boolean Success
* @deprecated
*/ */
function loadPluginComponent($plugin, $component) { function loadPluginComponent($plugin, $component) {
if (!class_exists($component . 'Component')) { if (!class_exists($component . 'Component')) {
@ -509,9 +513,8 @@
} else { } else {
return false; return false;
} }
} else {
return true;
} }
return true;
} }
/** /**
* Loads a behavior * Loads a behavior
@ -520,11 +523,14 @@
* @return boolean Success * @return boolean Success
*/ */
function loadBehavior($name) { function loadBehavior($name) {
$paths = Configure::getInstance();
if ($name === null) { if ($name === null) {
return true; return true;
} }
if(strpos($name, '.') !== false){
list($plugin, $name) = explode('.', $name);
}
$paths = Configure::getInstance();
if (!class_exists($name . 'Behavior')) { if (!class_exists($name . 'Behavior')) {
$name = Inflector::underscore($name); $name = Inflector::underscore($name);
@ -544,9 +550,8 @@
return false; return false;
} }
} }
} else {
return true;
} }
return true;
} }
/** /**
* Returns an array of filenames of PHP files in given directory. * Returns an array of filenames of PHP files in given directory.
@ -616,8 +621,14 @@
function vendor($name) { function vendor($name) {
$args = func_get_args(); $args = func_get_args();
$c = func_num_args(); $c = func_num_args();
for ($i = 0; $i < $c; $i++) { for ($i = 0; $i < $c; $i++) {
$arg = $args[$i]; $arg = $args[$i];
if(strpos($arg, '.') !== false){
list($plugin, $arg) = explode('.', $arg);
}
if (file_exists(APP . 'vendors' . DS . $arg . '.php')) { if (file_exists(APP . 'vendors' . DS . $arg . '.php')) {
require_once(APP . 'vendors' . DS . $arg . '.php'); require_once(APP . 'vendors' . DS . $arg . '.php');
} elseif (file_exists(VENDORS . $arg . '.php')) { } elseif (file_exists(VENDORS . $arg . '.php')) {