class AllDocsNormalizer in Replication 8
Same name and namespace in other branches
- 8.2 src/Normalizer/AllDocsNormalizer.php \Drupal\replication\Normalizer\AllDocsNormalizer
Hierarchy
- class \Drupal\serialization\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\SerializerAwareInterface, CacheableNormalizerInterface uses \Symfony\Component\Serializer\SerializerAwareTrait
- class \Drupal\replication\Normalizer\AllDocsNormalizer
Expanded class hierarchy of AllDocsNormalizer
1 string reference to 'AllDocsNormalizer'
1 service uses AllDocsNormalizer
File
- src/
Normalizer/ AllDocsNormalizer.php, line 7
Namespace
Drupal\replication\NormalizerView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AllDocsNormalizer:: |
protected | property |
The interface or class that this Normalizer supports. Overrides NormalizerBase:: |
|
AllDocsNormalizer:: |
public | function | Normalizes an object into a set of arrays/scalars. | |
CacheableNormalizerInterface:: |
constant | Name of key for bubbling cacheability metadata via serialization context. | ||
NormalizerBase:: |
protected | property | List of formats which supports (de-)normalization. | 3 |
NormalizerBase:: |
protected | function | Adds cacheability if applicable. | |
NormalizerBase:: |
protected | function | Checks if the provided format is supported by this normalizer. | 2 |
NormalizerBase:: |
public | function | Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() | 1 |
NormalizerBase:: |
public | function | Checks whether the given class is supported for normalization by this normalizer. | 1 |