getMessage()}"); } $rendererHtml = ""; /** * Snippet */ try { $style = $brandButton->getStyle(); } catch (ExceptionCompile $e) { $rendererHtml .= LogUtility::wrapInRedForHtml("The style of the share button ($brandButton) could not be determined. Error: {$e->getMessage()}"); return $rendererHtml; } $snippetId = $brandButton->getStyleScriptIdentifier(); PluginUtility::getSnippetManager()->attachCssInternalStyleSheet($snippetId, $style); /** * Standard link attribute * and Runtime Cache key dependencies */ try { ExecutionContext::getActualOrCreateFromEnv() ->getExecutingMarkupHandler() ->getOutputCacheDependencies() ->addDependency(MarkupCacheDependencies::REQUESTED_PAGE_DEPENDENCY); } catch (ExceptionNotFound $e) { // not a fetcher markup run } try { $requestedPage = MarkupPath::createFromRequestedPage(); } catch (ExceptionNotFound $e) { return LogUtility::wrapInRedForHtml("Share Error: Requested Page Not Found: ({$e->getMessage()}"); } try { $type = $shareAttributes->getType(); $buttonAttributes = $brandButton->getHtmlAttributes($requestedPage) ->setType($type) ->setLogicalTag($shareAttributes->getLogicalTag()); } catch (ExceptionCompile $e) { return LogUtility::wrapInRedForHtml("The social channel creation returns an error when creating the link ({$e->getMessage()}"); } /** * Add the link */ $rendererHtml = $buttonAttributes->toHtmlEnterTag("button"); /** * Icon */ if ($brandButton->hasIcon()) { try { $iconAttributes = $brandButton->getIconAttributes(); $tagIconAttributes = TagAttributes::createFromCallStackArray($iconAttributes); $rendererHtml .= Icon::createFromTagAttributes($tagIconAttributes) ->toHtml(); } catch (ExceptionCompile $e) { $message = "Getting the icon for the social channel ($brandButton) returns an error ({$e->getMessage()}"; if (PluginUtility::isDevOrTest()) { throw new ExceptionRuntime($message, self::CANONICAL, 1, $e); } $rendererHtml .= LogUtility::wrapInRedForHtml($message); // don't return because the anchor link is open } } /** * When empty tag, close the link */ if ($state === DOKU_LEXER_SPECIAL) { $rendererHtml .= ""; } return $rendererHtml; } public static function getKnownTypes(): array { return Brand::getBrandNamesForButtonType(BrandButton::TYPE_BUTTON_SHARE); } public static function renderExit(): string { return ""; } }