/** * @name updateMetadata * * Updates metadata with icons. * * @param SiteConfig $config * @param SiteTree $owner * @param $metadata * @return void */ public function updateMetadata(SiteConfig $config, SiteTree $owner, &$metadata) { // decode into array $data = json_decode($owner->OpenGraphData, true); // check for data or throw an error if ($data) { // check if off if ($data['og:type'] !== 'off') { // Header $metadata .= $owner->MarkupComment('Open Graph'); // Type $metadata .= $owner->MarkupOpenGraph('og:type', $data['og:type']); // URL $metadata .= $owner->MarkupOpenGraph('og:url', $owner->AbsoluteLink()); // Site Name $siteName = $data['og:site_name'] ? $data['og:site_name'] : $config->Title; $metadata .= $owner->MarkupOpenGraph('og:site_name', $siteName, true); // Title $title = $data['og:title'] ? $data['og:title'] : $owner->Title; $metadata .= $owner->MarkupOpenGraph('og:title', $title, true); // Description $description = $data['og:description'] ? $data['og:description'] : $owner->GenerateDescription(); $metadata .= $owner->MarkupOpenGraph('og:description', $description, true); // Image if ($owner->OpenGraphImage()->exists()) { $metadata .= $owner->MarkupOpenGraph('og:image', $owner->OpenGraphImage()->getAbsoluteURL()); } } else { // OFF $metadata .= $owner->MarkupComment('Open Graph [ off ]'); } } else { // ERROR $metadata .= $owner->MarkupComment('Open Graph [ error ]'); } }