Make isValid more compact and fix coding style

refs #5525
This commit is contained in:
Johannes Meyer 2014-07-24 09:05:10 +02:00
parent edf49d091e
commit 9c434fe8bf
1 changed files with 13 additions and 12 deletions

View File

@ -28,35 +28,36 @@ abstract class BaseBackendForm extends Form
}
/**
* Validate this form with the Zend validation mechanism and perform a logic validation of the connection.
* Return whether the given values are complete/valid and check whether it is possible to connect to the backend
*
* If logic validation fails, the 'backend_force_creation' checkbox is prepended to the form to allow users to
* skip the logic connection validation.
* If connection validation fails, a checkbox is prepended to the form to allow users to skip it.
*
* @param array $data The form input to validate
* @param array $data The data to validate
*
* @return bool Whether validation succeeded or not
* @return bool Whether the validation succeeded or not
*/
public function isValid($data)
{
if (!parent::isValid($data)) {
if (false === parent::isValid($data)) {
return false;
}
if (isset($data['backend_force_creation']) && $data['backend_force_creation']) {
return true;
}
if (!$this->isValidAuthenticationBackend()) {
if (
(false === isset($data['force_creation']) || false === $data['force_creation'])
&& false === $this->isValidAuthenticationBackend()
) {
$this->addForceCreationCheckbox();
return false;
}
return true;
}
/**
* Validate the configuration state of this backend with the concrete authentication backend.
*
* An implementation should not throw any exception, but use the add/setErrorMessages method of
* Zend_Form. If the 'backend_force_creation' checkbox is set, this method won't be called.
* An implementation should not throw any exception, but use the add/setErrorMessages method
* of Zend_Form. If the 'force_creation' checkbox is set, this method won't be called.
*
* @return bool Whether validation succeeded or not
*/