Refactoring how models are passed as a request parameter to the view, now the full plugin and model name will be passed on

This commit is contained in:
Jose Lorenzo Rodriguez 2011-07-13 23:47:45 -04:30
parent e45b35cffe
commit 567ac0209c

View file

@ -808,8 +808,8 @@ class Controller extends Object {
if (!empty($this->uses)) { if (!empty($this->uses)) {
foreach ($this->uses as $model) { foreach ($this->uses as $model) {
list($plugin, $model) = pluginSplit($model); list($plugin, $className) = pluginSplit($model);
$this->request->params['models'][$model] = $plugin; $this->request->params['models'][$model] = compact('plugin', 'className');
} }
} }
@ -817,10 +817,10 @@ class Controller extends Object {
foreach ($models as $currentModel) { foreach ($models as $currentModel) {
$currentObject = ClassRegistry::getObject($currentModel); $currentObject = ClassRegistry::getObject($currentModel);
if (is_a($currentObject, 'Model')) { if (is_a($currentObject, 'Model')) {
list($plugin, $package) = pluginSplit(App::location(get_class($currentObject))); $className = get_class($currentObject);
$this->request->params['models'][$currentObject->alias] = $plugin; list($plugin, $package) = pluginSplit(App::location($className));
$View->validationErrors[$currentObject->alias] =& $this->request->params['models'][$currentObject->alias] = compact('plugin', 'className');
$currentObject->validationErrors; $View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors;
} }
} }