You are here

trait SyncNormalizerDecoratorTrait in Content Synchronization 3.0.x

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

Hierarchy

1 file declares its use of SyncNormalizerDecoratorTrait
ContentEntityNormalizer.php in src/Normalizer/ContentEntityNormalizer.php

File

src/Plugin/SyncNormalizerDecoratorTrait.php, line 7

Namespace

Drupal\content_sync\Plugin
View source
trait SyncNormalizerDecoratorTrait {
  protected function decorateNormalization(array &$normalized_entity, ContentEntityInterface $entity, $format, array $context = []) {
    $plugins = $this
      ->getDecoratorManager()
      ->getDefinitions();
    foreach ($plugins as $decorator) {

      /* @var $instance SyncNormalizerDecoratorInterface */
      $instance = $this
        ->getDecoratorManager()
        ->createInstance($decorator['id']);
      $instance
        ->decorateNormalization($normalized_entity, $entity, $format, $context);
    }
  }
  protected function decorateDenormalization(array &$normalized_entity, $type, $format, array $context = []) {
    $plugins = $this
      ->getDecoratorManager()
      ->getDefinitions();
    foreach ($plugins as $decorator) {

      /* @var $instance SyncNormalizerDecoratorInterface */
      $instance = $this
        ->getDecoratorManager()
        ->createInstance($decorator['id']);
      $instance
        ->decorateDenormalization($normalized_entity, $type, $format, $context);
    }
  }
  protected function decorateDenormalizedEntity(ContentEntityInterface $entity, array $normalized_entity, $format, array $context = []) {
    $plugins = $this
      ->getDecoratorManager()
      ->getDefinitions();
    foreach ($plugins as $decorator) {

      /* @var $instance SyncNormalizerDecoratorInterface */
      $instance = $this
        ->getDecoratorManager()
        ->createInstance($decorator['id']);
      $instance
        ->decorateDenormalizedEntity($entity, $normalized_entity, $format, $context);
    }
  }

  /**
   * @return SyncNormalizerDecoratorManager
   */
  protected abstract function getDecoratorManager();

}

Members