function ViewExecutable::validate

Same name in other branches
  1. 9 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::validate()
  2. 8.9.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::validate()
  3. 10 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::validate()

Makes sure the view is completely valid.

Return value

array An array of error strings. This will be empty if there are no validation errors.

File

core/modules/views/src/ViewExecutable.php, line 2148

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function validate() {
    $errors = [];
    $this->initDisplay();
    $current_display = $this->current_display;
    foreach ($this->displayHandlers as $id => $display) {
        if (!empty($display)) {
            if (!empty($display->display['deleted'])) {
                continue;
            }
            $result = $this->displayHandlers
                ->get($id)
                ->validate();
            if (!empty($result) && is_array($result)) {
                $errors[$id] = $result;
            }
        }
    }
    $this->setDisplay($current_display);
    return $errors;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.