You are here

public function BlockContentNormalizer::normalize in Fixed Block Content 8

Overrides ContentEntityNormalizer::normalize

File

src/Normalizer/BlockContentNormalizer.php, line 22

Class

BlockContentNormalizer
Block content normalizer to store as fixed content block default value.

Namespace

Drupal\fixed_block_content\Normalizer

Code

public function normalize($object, $format = NULL, array $context = []) {
  $attributes = parent::normalize($object, $format, $context);
  if (isset($context['fixed_block_content'])) {

    // Remove local entity IDs.
    $ids = [
      'id',
      'revision_id',
      'uuid',
      'changed',
      'revision_created',
      'revision_user',
    ];
    foreach ($ids as $id) {
      unset($attributes[$id]);
    }
  }
  return $attributes;
}