You are here

public function ResourceResponseValidator::setValidator in Drupal 8

Same name and namespace in other branches
  1. 9 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();
  }
}