You are here

public function MultiresponseNormalizer::supportsNormalization in Subrequests 8.2

Same name and namespace in other branches
  1. 8 src/Normalizer/MultiresponseNormalizer.php \Drupal\subrequests\Normalizer\MultiresponseNormalizer::supportsNormalization()
  2. 3.x src/Normalizer/MultiresponseNormalizer.php \Drupal\subrequests\Normalizer\MultiresponseNormalizer::supportsNormalization()

File

src/Normalizer/MultiresponseNormalizer.php, line 47

Class

MultiresponseNormalizer
Normalizes multiple response objects into a single string.

Namespace

Drupal\subrequests\Normalizer

Code

public function supportsNormalization($data, $format = NULL) {
  if ($format !== 'multipart-related') {
    return FALSE;
  }
  if (!is_array($data)) {
    return FALSE;
  }
  $responses = array_filter($data, function ($response) {
    return $response instanceof Response;
  });
  if (count($responses) !== count($data)) {
    return FALSE;
  }
  return TRUE;
}