You are here

class RevsDiffNormalizer in Replication 8

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

Hierarchy

  • class \Drupal\serialization\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\SerializerAwareInterface, CacheableNormalizerInterface uses \Symfony\Component\Serializer\SerializerAwareTrait
    • class \Drupal\replication\Normalizer\RevsDiffNormalizer implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface

Expanded class hierarchy of RevsDiffNormalizer

1 string reference to 'RevsDiffNormalizer'
replication.services.yml in ./replication.services.yml
replication.services.yml
1 service uses RevsDiffNormalizer
replication.normalizer.revs_diff in ./replication.services.yml
Drupal\replication\Normalizer\RevsDiffNormalizer

File

src/Normalizer/RevsDiffNormalizer.php, line 10

Namespace

Drupal\replication\Normalizer
View source
class RevsDiffNormalizer extends NormalizerBase implements DenormalizerInterface {

  /**
   * @var string[]
   */
  protected $supportedInterfaceOrClass = [
    'Drupal\\replication\\RevisionDiff\\RevisionDiffInterface',
  ];

  /**
   * @var string[]
   */
  protected $format = [
    'json',
  ];

  /** @var  \Drupal\replication\RevisionDiffFactoryInterface */
  protected $revisionDiffFactory;
  public function __construct(RevisionDiffFactoryInterface $revisiondiff_factory) {
    $this->revisionDiffFactory = $revisiondiff_factory;
  }

  /**
   * {@inheritdoc}
   */
  public function normalize($rev_diff, $format = NULL, array $context = []) {

    /** @var \Drupal\replication\RevisionDiff\RevisionDiffInterface $rev_diff */
    $missing = $rev_diff
      ->getMissing();
    return $missing ?: new \stdClass();
  }

  /**
   * {@inheritdoc}
   */
  public function denormalize($data, $class, $format = NULL, array $context = []) {
    if (!isset($context['workspace'])) {
      throw new LogicException('A \'workspace\' context is required to denormalize revision diff data.');
    }
    return $this->revisionDiffFactory
      ->get($context['workspace'])
      ->setRevisionIds($data);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY constant Name of key for bubbling cacheability metadata via serialization context.
NormalizerBase::addCacheableDependency protected function Adds cacheability if applicable.
NormalizerBase::checkFormat protected function Checks if the provided format is supported by this normalizer. 2
NormalizerBase::supportsDenormalization public function Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() 1
NormalizerBase::supportsNormalization public function Checks whether the given class is supported for normalization by this normalizer. 1
RevsDiffNormalizer::$format protected property Overrides NormalizerBase::$format
RevsDiffNormalizer::$revisionDiffFactory protected property @var \Drupal\replication\RevisionDiffFactoryInterface
RevsDiffNormalizer::$supportedInterfaceOrClass protected property Overrides NormalizerBase::$supportedInterfaceOrClass
RevsDiffNormalizer::denormalize public function Denormalizes data back into an object of the given class.
RevsDiffNormalizer::normalize public function Normalizes an object into a set of arrays/scalars.
RevsDiffNormalizer::__construct public function