You are here

class ChangesNormalizer in Replication 8.2

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

Hierarchy

Expanded class hierarchy of ChangesNormalizer

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

File

src/Normalizer/ChangesNormalizer.php, line 7

Namespace

Drupal\replication\Normalizer
View source
class ChangesNormalizer extends NormalizerBase {
  protected $supportedInterfaceOrClass = [
    'Drupal\\replication\\Changes\\ChangesInterface',
  ];

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

    /** @var \Drupal\replication\Changes\ChangesInterface $changes */
    if (isset($context['query']['filter'])) {
      $changes
        ->filter($context['query']['filter']);
    }
    if (isset($context['query']['parameters'])) {
      $changes
        ->parameters($context['query']['parameters']);
    }
    if (isset($context['query']['limit'])) {
      $changes
        ->setLimit($context['query']['limit']);
    }
    $since = isset($context['query']['since']) && is_numeric($context['query']['since']) ? $context['query']['since'] : 0;
    $changes
      ->setSince($since);
    $results = $changes
      ->getNormal();
    $last_result = end($results);
    $last_seq = isset($last_result['seq']) ? $last_result['seq'] : 0;
    return [
      'last_seq' => $last_seq,
      'results' => $results,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY constant Name of key for bubbling cacheability metadata via serialization context.
ChangesNormalizer::$supportedInterfaceOrClass protected property The interface or class that this Normalizer supports. Overrides NormalizerBase::$supportedInterfaceOrClass
ChangesNormalizer::normalize public function Normalizes an object into a set of arrays/scalars.
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. 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