You are here

TextItemNormalizer.php in Replication 8.2

File

src/Normalizer/TextItemNormalizer.php
View source
<?php

namespace Drupal\replication\Normalizer;

use Drupal\serialization\Normalizer\FieldItemNormalizer;

/**
 * Converts TextItem fields to an array including computed values.
 */
class TextItemNormalizer extends FieldItemNormalizer {

  /**
   * The interface or class that this Normalizer supports.
   *
   * @var string
   */
  protected $supportedInterfaceOrClass = 'Drupal\\text\\Plugin\\Field\\FieldType\\TextItemBase';

  /**
   * {@inheritdoc}
   */
  public function normalize($object, $format = NULL, array $context = []) {
    $attributes = [];
    foreach ($object
      ->getProperties(TRUE) as $name => $field) {
      $attributes[$name] = $this->serializer
        ->normalize($field, $format, $context);
    }
    return $attributes;
  }

}

Classes

Namesort descending Description
TextItemNormalizer Converts TextItem fields to an array including computed values.