You are here

public function ResourceResponseValidator::setValidator in JSON:API 8.2

Same name and namespace in other branches
  1. 8 src/EventSubscriber/ResourceResponseValidator.php \Drupal\jsonapi\EventSubscriber\ResourceResponseValidator::setValidator()

Sets the validator service if available.

File

src/EventSubscriber/ResourceResponseValidator.php, line 110

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();
  }
}