function ComponentValidator::setValidator

Same name in this branch
  1. 11.x core/modules/sdc/src/Component/ComponentValidator.php \Drupal\sdc\Component\ComponentValidator::setValidator()
Same name in other branches
  1. 10 core/modules/sdc/src/Component/ComponentValidator.php \Drupal\sdc\Component\ComponentValidator::setValidator()
  2. 10 core/lib/Drupal/Core/Theme/Component/ComponentValidator.php \Drupal\Core\Theme\Component\ComponentValidator::setValidator()

Sets the validator service if available.

File

core/lib/Drupal/Core/Theme/Component/ComponentValidator.php, line 28

Class

ComponentValidator
Validates a component based on its definition and the component schema.

Namespace

Drupal\Core\Theme\Component

Code

public function setValidator(?Validator $validator = NULL) : void {
    if ($validator) {
        $this->validator = $validator;
        return;
    }
    if (class_exists(Validator::class)) {
        $this->validator = new Validator();
    }
}

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