prepareActionLinks($cube, $view);
} catch (Exception $e) {
$html[] = self::renderErrorItem($e, $view);
}
foreach ($hook->getActionLinks()->getLinks() as $link) {
$html[] = '
' . $link->render($view) . '';
}
}
if (empty($html)) {
$html[] = self::renderErrorItem(
$view->translate('No action links have been provided for this cube'),
$view
);
}
return implode("\n", $html) . "\n";
}
/**
* @param Exception|string $error
* @param View $view
* @return string
*/
private static function renderErrorItem($error, View $view)
{
if ($error instanceof Exception) {
$error = $error->getMessage();
}
return '' . $view->escape($error) . '';
}
/**
* Add an ActionLink to this set of actions
*
* @param ActionLink $link
* @return $this
*/
public function add(ActionLink $link)
{
$this->links[] = $link;
return $this;
}
/**
* @return ActionLink[]
*/
public function getLinks()
{
return $this->links;
}
/**
* @param View $view
*
* @return string
*/
public function render(View $view)
{
$links = $this->getLinks();
if (empty($links)) {
return '';
}
$html = '';
foreach ($links as $link) {
$html .= $link->render($view);
}
$html .= '
';
return $html;
}
}