actionLinks; } /** * Helper method to populate action links array * * @param Url $url * @param string $title * @param string $description * @param string $icon * * @return $this */ final protected function addActionLink(Url $url, string $title, string $description, string $icon): self { $linkContent = (new HtmlDocument()); $linkContent->addHtml(new Icon($icon)); $linkContent->addHtml(HtmlElement::create('span', ['class' => 'title'], $title)); $linkContent->addHtml(HtmlElement::create('p', null, $description)); $this->actionLinks[] = new Link($linkContent, $url); return $this; } /** * Helper method instantiating an Url object * * @param string $path * @param array $params * @return Url */ final protected function makeUrl(string $path, array $params = null): Url { $url = Url::fromPath($path); if ($params !== null) { $url->getParams()->mergeValues($params); } return $url; } /** * Render all links for all Hook implementations * * This is what the Cube calls when rendering details * * @param IcingaDbCube $cube * * @return string */ public static function renderAll(Cube $cube) { $html = new HtmlDocument(); /** @var IcingaDbActionsHook $hook */ foreach (Hook::all('Cube/IcingaDbActions') as $hook) { try { $hook->createActionLinks($cube); } catch (Exception $e) { $html->addHtml(HtmlElement::create('li', ['class' => 'error'], $e->getMessage())); } foreach ($hook->getActionLinks() as $link) { $html->addHtml(HtmlElement::create('li', null, $link)); } } if ($html->isEmpty()) { $html->addHtml( HtmlElement::create( 'li', ['class' => 'error'], t('No action links have been provided for this cube') ) ); } return $html->render(); } }