You are here

class TextItemNormalizer in Content Synchronization 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Normalizer/TextItemNormalizer.php \Drupal\content_sync\Normalizer\TextItemNormalizer

Converts TextItem fields to an array including computed values.

Hierarchy

Expanded class hierarchy of TextItemNormalizer

1 string reference to 'TextItemNormalizer'
content_sync.services.yml in ./content_sync.services.yml
content_sync.services.yml
1 service uses TextItemNormalizer
content_sync.normalizer.text_item in ./content_sync.services.yml
Drupal\content_sync\Normalizer\TextItemNormalizer

File

src/Normalizer/TextItemNormalizer.php, line 10

Namespace

Drupal\content_sync\Normalizer
View source
class TextItemNormalizer extends NormalizerBase {

  /**
   * 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) {
      $value = $this->serializer
        ->normalize($field, $format, $context);
      if (is_object($value)) {
        $value = $this->serializer
          ->normalize($value, $format, $context);
      }
      $attributes[$name] = $value;
    }
    return $attributes;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY constant Name of key for bubbling cacheability metadata via serialization context.
NormalizerBase::$format protected property List of formats which supports (de-)normalization. 3
NormalizerBase::addCacheableDependency protected function Adds cacheability if applicable.
NormalizerBase::checkFormat protected function Checks if the provided format is supported by this normalizer. 1
NormalizerBase::supportsDenormalization public function Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() 1
NormalizerBase::supportsNormalization public function 1
TextItemNormalizer::$supportedInterfaceOrClass protected property The interface or class that this Normalizer supports. Overrides NormalizerBase::$supportedInterfaceOrClass
TextItemNormalizer::normalize public function