X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fmetatag%2Fsrc%2FNormalizer%2FMetatagNormalizer.php;fp=web%2Fmodules%2Fcontrib%2Fmetatag%2Fsrc%2FNormalizer%2FMetatagNormalizer.php;h=32837dcd68897f70671666db91559c1a0cd6f666;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/modules/contrib/metatag/src/Normalizer/MetatagNormalizer.php b/web/modules/contrib/metatag/src/Normalizer/MetatagNormalizer.php new file mode 100644 index 000000000..32837dcd6 --- /dev/null +++ b/web/modules/contrib/metatag/src/Normalizer/MetatagNormalizer.php @@ -0,0 +1,53 @@ +getEntity(); + + $tags = metatag_get_tags_from_route($entity); + + $normalized['value'] = []; + if (isset($tags['#attached']['html_head'])) { + foreach ($tags['#attached']['html_head'] as $tag) { + // @todo Work out a proper, long-term fix for this. + if (isset($tag[0]['#attributes']['content'])) { + $normalized['value'][$tag[1]] = $tag[0]['#attributes']['content']; + } + elseif (isset($tag[0]['#attributes']['href'])) { + $normalized['value'][$tag[1]] = $tag[0]['#attributes']['href']; + } + } + } + + if (isset($context['langcode'])) { + $normalized['lang'] = $context['langcode']; + } + + return $normalized; + } + + /** + * {@inheritdoc} + */ + public function supportsDenormalization($data, $type, $format = NULL) { + return FALSE; + } + +}