Skip to content

Commit

Permalink
Do not prepare object name HTML to render the link
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed May 28, 2024
1 parent 7c4b7c6 commit 1252985
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions library/Notifications/Hook/ObjectsRendererHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
use Icinga\Application\Logger;
use Icinga\Module\Notifications\Model\Objects;
use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlElement;
use ipl\Html\HtmlString;
use ipl\Html\Text;
use ipl\Html\ValidHtml;
use ipl\Web\Url;
use ipl\Web\Widget\Link;
Expand Down Expand Up @@ -197,9 +198,9 @@ function ($object) {
*
* @param Objects $obj
*
* @return ValidHtml
* @return BaseHtmlElement
*/
final public static function getObjectName(Objects $obj): ValidHtml
final public static function getObjectName(Objects $obj): BaseHtmlElement
{
$objId = $obj->id;
if (! isset(self::$objectNameHtmls[$objId])) {
Expand All @@ -210,7 +211,11 @@ final public static function getObjectName(Objects $obj): ValidHtml
return self::$objectNameHtmls[$objId];
}

self::$objectNameHtmls[$objId] = new HtmlString(self::createObjectNameAsString($obj));
self::$objectNameHtmls[$objId] = new HtmlElement(
'div',
null,
Text::create(self::createObjectNameAsString($obj))
);

return self::$objectNameHtmls[$objId];
}
Expand Down Expand Up @@ -293,7 +298,7 @@ final public static function renderObjectLink(Objects $object): ?ValidHtml
$objUrl = Url::fromPath($object->url);

return new Link(
self::getObjectName($object),
Text::create(self::createObjectNameAsString($object)),
$objUrl->isExternal() ? $objUrl->getAbsoluteUrl() : $objUrl->getRelativeUrl(),
['class' => 'subject', 'data-base-target' => '_next']
);
Expand Down

0 comments on commit 1252985

Please sign in to comment.