MetatagNormalizer.php in Replication 8
File
src/Normalizer/MetatagNormalizer.php
View source
<?php
namespace Drupal\replication\Normalizer;
use Drupal\serialization\Normalizer\FieldNormalizer;
class MetatagNormalizer extends FieldNormalizer {
protected $supportedInterfaceOrClass = 'Drupal\\metatag\\Plugin\\Field\\MetatagEntityFieldItemList';
protected $format = [
'json',
];
public function normalize($field_item, $format = NULL, array $context = []) {
$normalized = [];
if (\Drupal::hasService('metatag.normalizer.metatag')) {
$normalized = \Drupal::service('metatag.normalizer.metatag')
->normalize($field_item, $format, $context);
}
return [
$normalized,
];
}
public function denormalize($data, $class, $format = NULL, array $context = []) {
return parent::denormalize($data, $class, $format, $context);
}
public function supportsDenormalization($data, $type, $format = NULL) {
if (in_array($type, [
'Drupal\\metatag\\Plugin\\Field\\MetatagEntityFieldItemList',
])) {
return TRUE;
}
return FALSE;
}
}