class RenderNormalizer in REST Views 8
Same name and namespace in other branches
- 2.0.x src/Normalizer/RenderNormalizer.php \Drupal\rest_views\Normalizer\RenderNormalizer
Unwrap a RenderableData object and render the element inside.
@package Drupal\rest_views\Normalizer
Hierarchy
- class \Drupal\serialization\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\SerializerAwareInterface, CacheableNormalizerInterface uses \Symfony\Component\Serializer\SerializerAwareTrait
- class \Drupal\rest_views\Normalizer\RenderNormalizer
Expanded class hierarchy of RenderNormalizer
1 file declares its use of RenderNormalizer
- EntityFieldExportTest.php in tests/
src/ Unit/ EntityFieldExportTest.php
1 string reference to 'RenderNormalizer'
1 service uses RenderNormalizer
File
- src/
Normalizer/ RenderNormalizer.php, line 14
Namespace
Drupal\rest_views\NormalizerView source
class RenderNormalizer extends NormalizerBase {
/**
* The interface or class that this Normalizer supports.
*
* @var array
*/
protected $supportedInterfaceOrClass = [
RenderableData::class,
];
/**
* The renderer service.
*
* @var \Drupal\Core\Render\RendererInterface
*/
protected $renderer;
/**
* DataNormalizer constructor.
*
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer service.
*/
public function __construct(RendererInterface $renderer) {
$this->renderer = $renderer;
}
/**
* {@inheritdoc}
*
* @throws \Exception
*/
public function normalize($object, $format = NULL, array $context = []) {
/** @var \Drupal\rest_views\SerializedData $object */
/** @var \Symfony\Component\Serializer\Normalizer\NormalizerInterface $normalizer */
$normalizer = $this->serializer;
$data = $object
->getData();
return $normalizer
->normalize($this->renderer
->render($data));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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 |
RenderNormalizer:: |
protected | property | The renderer service. | |
RenderNormalizer:: |
protected | property |
The interface or class that this Normalizer supports. Overrides NormalizerBase:: |
|
RenderNormalizer:: |
public | function | ||
RenderNormalizer:: |
public | function | DataNormalizer constructor. |