Example #1
0
 /**
  * Run the configured backend's inspection checks and show the result, if necessary
  *
  * This will only run any validation if the user pushed the 'backend_validation' button.
  *
  * @param   array   $formData
  *
  * @return  bool
  */
 public function isValidPartial(array $formData)
 {
     if (isset($formData['backend_validation']) && parent::isValid($formData)) {
         $self = clone $this;
         if (($resourceElement = $self->getSubForm('backend_form')->getElement('resource')) !== null) {
             $resourceElement->setIgnore(false);
         }
         $inspection = UserBackendConfigForm::inspectUserBackend($self);
         if ($inspection !== null) {
             $join = function ($e) use(&$join) {
                 return is_string($e) ? $e : join("\n", array_map($join, $e));
             };
             $this->addElement('note', 'inspection_output', array('order' => 0, 'value' => '<strong>' . $this->translate('Validation Log') . "</strong>\n\n" . join("\n", array_map($join, $inspection->toArray())), 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'pre', 'class' => 'log-output')))));
             if ($inspection->hasError()) {
                 $this->warning(sprintf($this->translate('Failed to successfully validate the configuration: %s'), $inspection->getError()));
                 return false;
             }
         }
         $this->info($this->translate('The configuration has been successfully validated.'));
     } elseif (!isset($formData['backend_validation'])) {
         // This is usually done by isValid(Partial), but as we're not calling any of these...
         $this->populate($formData);
     }
     return true;
 }