You are here

class AllDocsNormalizer in Replication 8

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

Hierarchy

Expanded class hierarchy of AllDocsNormalizer

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

File

src/Normalizer/AllDocsNormalizer.php, line 7

Namespace

Drupal\replication\Normalizer
View source
class AllDocsNormalizer extends NormalizerBase {
  protected $supportedInterfaceOrClass = [
    'Drupal\\replication\\AllDocs\\AllDocsInterface',
  ];

  /**
   * {@inheritdoc}
   */
  public function normalize($all_docs, $format = NULL, array $context = []) {
    $data = [
      'offset' => 0,
      'rows' => [],
    ];

    /** @var \Drupal\replication\AllDocs\AllDocsInterface $all_docs */
    if (!empty($context['query']['include_docs'])) {
      $all_docs
        ->includeDocs(TRUE);
    }
    $rows = $all_docs
      ->execute();
    foreach ($rows as $key => $value) {
      $data['rows'][] = [
        'id' => $key,
        'key' => $key,
        'value' => $value,
      ];
    }
    $data['total_rows'] = count($rows);
    return $data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AllDocsNormalizer::$supportedInterfaceOrClass protected property The interface or class that this Normalizer supports. Overrides NormalizerBase::$supportedInterfaceOrClass
AllDocsNormalizer::normalize public function Normalizes an object into a set of arrays/scalars.
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. 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