function ResourceResponseValidator::setValidator

Same name in other branches
  1. 8.9.x core/modules/jsonapi/src/EventSubscriber/ResourceResponseValidator.php \Drupal\jsonapi\EventSubscriber\ResourceResponseValidator::setValidator()
  2. 10 core/modules/jsonapi/src/EventSubscriber/ResourceResponseValidator.php \Drupal\jsonapi\EventSubscriber\ResourceResponseValidator::setValidator()
  3. 11.x core/modules/jsonapi/src/EventSubscriber/ResourceResponseValidator.php \Drupal\jsonapi\EventSubscriber\ResourceResponseValidator::setValidator()

Sets the validator service if available.

File

core/modules/jsonapi/src/EventSubscriber/ResourceResponseValidator.php, line 87

Class

ResourceResponseValidator
Response subscriber that validates a JSON:API response.

Namespace

Drupal\jsonapi\EventSubscriber

Code

public function setValidator(Validator $validator = NULL) {
    if ($validator) {
        $this->validator = $validator;
    }
    elseif (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.