Removing need for plugins to need a model

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4485 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-02-09 02:38:19 +00:00
parent 24fd9b1e9b
commit 1c07701223

View file

@ -89,26 +89,26 @@
if(!class_exists('AppModel')){ if(!class_exists('AppModel')){
loadModel(); loadModel();
} }
$pluginAppModel = Inflector::camelize($plugin . '_app_model'); $pluginAppModel = Inflector::camelize($plugin . '_app_model');
$pluginAppModelFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_model.php'; $pluginAppModelFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_model.php';
if (!class_exists($pluginAppModel)) { if (!class_exists($pluginAppModel)) {
if (file_exists($pluginAppModelFile)) { if (file_exists($pluginAppModelFile)) {
require($pluginAppModelFile); require($pluginAppModelFile);
} else { Overloadable::overload($pluginAppModel);
die(sprintf(__("Plugins must have a class named %s", true), $pluginAppModel));
} }
Overloadable::overload($pluginAppModel);
} }
$pluginModelDir = APP . 'plugins' . DS . $plugin . DS . 'models' . DS; $pluginModelDir = APP . 'plugins' . DS . $plugin . DS . 'models' . DS;
if(is_dir($pluginModelDir)) {
foreach(listClasses($pluginModelDir)as $modelFileName) {
list($name) = explode('.', $modelFileName);
$className = Inflector::camelize($name);
foreach(listClasses($pluginModelDir)as $modelFileName) { if (!class_exists($className)) {
list($name) = explode('.', $modelFileName); require($pluginModelDir . $modelFileName);
$className = Inflector::camelize($name); Overloadable::overload($className);
}
if (!class_exists($className)) {
require($pluginModelDir . $modelFileName);
Overloadable::overload($className);
} }
} }
} }