Skip to content

Commit

Permalink
following coding standards and simplifying some logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Apr 29, 2012
1 parent 8eb02d0 commit f54eb0c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/Cake/Model/ModelValidator.php
Expand Up @@ -241,17 +241,18 @@ public function invalidFields($options = array()) {
if (!$this->propagateBeforeValidate($options)) {
return false;
}
$model = $this->getModel();
$this->data = array();

$this->setOptions($options);

if (!$this->setFields()) {
return $this->getModel()->validationErrors = $this->validationErrors;
return $model->validationErrors = $this->validationErrors;
}

$this->getData();
$this->getMethods();
$this->setValidationDomain();
$this->setValidationDomain($model->validationDomain);

foreach ($this->_fields as $field) {
$field->validate();
Expand Down Expand Up @@ -350,7 +351,7 @@ public function getFields($name = null) {
}

/**
* Sets the CakeField isntances from the Model::$validate property after processing the fieldList and whiteList.
* Sets the CakeField instances from the Model::$validate property after processing the fieldList and whiteList.
* If Model::$validate is not set or empty, this method returns false. True otherwise.
*
* @param boolean $reset If true will reset the Validator $validate array to the Model's default
Expand Down Expand Up @@ -413,10 +414,10 @@ public function setOption($name, $value = null) {
* @param string $name The options name to look up
* @return mixed Either null or the option value
*/
public function getOptions($name = NULL) {
if (NULL !== $name) {
public function getOptions($name = null) {
if ($name !== null) {
if (!isset($this->options[$name])) {
return NULL;
return null;
}
return $this->options[$name];
}
Expand All @@ -432,8 +433,6 @@ public function getOptions($name = NULL) {
public function setValidationDomain($validationDomain = null) {
if ($validationDomain !== null) {
$this->validationDomain = $validationDomain;
} elseif ($this->_model->validationDomain !== null) {
$this->validationDomain = $this->_model->validationDomain;
} else {
$this->validationDomain = ModelValidator::DEFAULT_DOMAIN;
}
Expand Down Expand Up @@ -471,7 +470,7 @@ protected function _processWhitelist() {
if (!empty($whitelist)) {
$this->validationErrors = array();
$validate = array();
foreach ((array) $whitelist as $f) {
foreach ((array)$whitelist as $f) {
if (!empty($this->_validate[$f])) {
$validate[$f] = $this->_validate[$f];
}
Expand Down

0 comments on commit f54eb0c

Please sign in to comment.