You are here

public function ReplicationLogNormalizer::supportsDenormalization in Replication 8.2

Same name and namespace in other branches
  1. 8 src/Normalizer/ReplicationLogNormalizer.php \Drupal\replication\Normalizer\ReplicationLogNormalizer::supportsDenormalization()

Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()

This class doesn't implement DenormalizerInterface, but most of its child classes do. Therefore, this method is implemented at this level to reduce code duplication.

Overrides NormalizerBase::supportsDenormalization

File

src/Normalizer/ReplicationLogNormalizer.php, line 84

Class

ReplicationLogNormalizer

Namespace

Drupal\replication\Normalizer

Code

public function supportsDenormalization($data, $type, $format = NULL) {

  // We need to accept both ReplicationLog and ContentEntityInterface classes.
  // LocalDocResource entities are treated as standard documents (content entities)
  if (in_array($type, [
    'Drupal\\Core\\Entity\\ContentEntityInterface',
    'Drupal\\replication\\Entity\\ReplicationLog',
  ], true)) {

    // If a document doesn't have a type set, we assume it's a replication log.
    // We also support documents specifically specified as replication logs.
    if (!isset($data['@type']) || $data['@type'] === 'replication_log') {
      return true;
    }
  }
  return false;
}