Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

extract the validationErrors logic

  • Loading branch information...
commit 20820d5dad130e3d229d11ce029ffaedf275327d 1 parent ec7ec73
@AD7six AD7six authored
Showing with 27 additions and 11 deletions.
  1. +27 −11 lib/Cake/Controller/Controller.php
View
38 lib/Cake/Controller/Controller.php
@@ -940,17 +940,7 @@ public function render($view = null, $layout = null) {
}
$View = new $viewClass($this);
-
- $models = ClassRegistry::keys();
- foreach ($models as $currentModel) {
- $currentObject = ClassRegistry::getObject($currentModel);
- if (is_a($currentObject, 'Model')) {
- $className = get_class($currentObject);
- list($plugin) = pluginSplit(App::location($className));
- $this->request->params['models'][$currentObject->alias] = compact('plugin', 'className');
- $View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors;
- }
- }
+ $View->validationErrors = $this->_validationErrors();
$this->autoRender = false;
$this->View = $View;
@@ -1225,4 +1215,30 @@ protected function _scaffoldError($method) {
return $this->scaffoldError($method);
}
+/**
+ * _validationErrors
+ *
+ * Get all validation errors for the current request
+ *
+ * @return array
+ */
+ protected function _validationErrors() {
+ $return = array();
+
+ $models = ClassRegistry::keys();
+ foreach ($models as $model) {
+ $object = ClassRegistry::getObject($model);
+ if (!is_a($object, 'Model')) {
+ continue;
+ }
+ $className = get_class($object);
+ if (array_key_exists($object->alias, $return)) {
+ continue;
+ }
+ list($plugin) = pluginSplit(App::location($className));
+ $return[$object->alias] =& $object->validationErrors;
+ }
+ return $return;
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.