You are here

public function AttachmentNormalizer::normalize in Replication 8

Same name and namespace in other branches
  1. 8.2 src/Normalizer/AttachmentNormalizer.php \Drupal\replication\Normalizer\AttachmentNormalizer::normalize()

Overrides ContentEntityNormalizer::normalize

File

src/Normalizer/AttachmentNormalizer.php, line 24

Class

AttachmentNormalizer

Namespace

Drupal\replication\Normalizer

Code

public function normalize($data, $format = NULL, array $context = []) {

  // If the 'new_revision_id' context is TRUE then normalize file entity as a
  // content entity not stream.
  if (!empty($context['new_revision_id'])) {
    return parent::normalize($data, $format, $context);
  }

  /** @var \Drupal\file\FileInterface $data */
  $stream = fopen($data
    ->getFileUri(), 'r');
  return $stream;
}