You are here

protected function NormalizerBase::checkFormat in Drupal 9

Same name in this branch
  1. 9 core/modules/jsonapi/src/Normalizer/NormalizerBase.php \Drupal\jsonapi\Normalizer\NormalizerBase::checkFormat()
  2. 9 core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase::checkFormat()
Same name and namespace in other branches
  1. 8 core/modules/jsonapi/src/Normalizer/NormalizerBase.php \Drupal\jsonapi\Normalizer\NormalizerBase::checkFormat()
  2. 10 core/modules/jsonapi/src/Normalizer/NormalizerBase.php \Drupal\jsonapi\Normalizer\NormalizerBase::checkFormat()

Checks if the provided format is supported by this normalizer.

Parameters

string $format: The format to check.

Return value

bool TRUE if the format is supported, FALSE otherwise. If no format is specified this will return TRUE.

Overrides NormalizerBase::checkFormat

File

core/modules/jsonapi/src/Normalizer/NormalizerBase.php, line 63

Class

NormalizerBase
Base normalizer used in all JSON:API normalizers.

Namespace

Drupal\jsonapi\Normalizer

Code

protected function checkFormat($format = NULL) {

  // The parent implementation allows format-specific normalizers to be used
  // for formatless normalization. The JSON:API module wants to be cautious.
  // Hence it only allows its normalizers to be used for the JSON:API format,
  // to avoid JSON:API-specific normalizations showing up in the REST API.
  return $format === $this->format;
}