public function ViewExecutable::validate

Make sure the view is completely valid.

Return value

TRUE if the view is valid; an array of error strings if it is not.

File

drupal/core/modules/views/lib/Drupal/views/ViewExecutable.php, line 1901
Definition of Drupal\views\ViewExecutable.

Class

ViewExecutable
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Namespace

Drupal\views

Code

public function validate() {
  $this
    ->initDisplay();
  $errors = array();
  $this->display_errors = NULL;
  $current_display = $this->current_display;
  foreach ($this->displayHandlers as $id => $display) {
    if (!empty($display)) {
      if (!empty($display->deleted)) {
        continue;
      }
      $result = $this->displayHandlers[$id]
        ->validate();
      if (!empty($result) && is_array($result)) {
        $errors = array_merge($errors, $result);

        // Mark this display as having validation errors.
        $this->display_errors[$id] = TRUE;
      }
    }
  }
  $this
    ->setDisplay($current_display);
  return $errors ? $errors : TRUE;
}