55
66namespace Icinga \Module \Notifications \Widget \Detail ;
77
8+ use Icinga \Application \ClassLoader ;
89use Icinga \Application \Config ;
910use Icinga \Module \Notifications \Common \Auth ;
1011use Icinga \Module \Notifications \Common \SourceHookLocator ;
@@ -77,21 +78,24 @@ protected function createContacts(): array
7778 protected function createRelatedObject (): array
7879 {
7980 $ object = $ this ->incident ->object ;
80- $ objectUrl = SourceHookLocator::forType ($ object ->source ->type )
81- ?->createObjectLink($ object ->id_tags );
81+ $ hook = SourceHookLocator::forType ($ object ->source ->type );
8282
83- if (! $ objectUrl ) {
84- if (! $ object ->url ) {
83+ $ objectUrl = $ hook ?->createObjectLink($ object ->id_tags );
84+ if ($ objectUrl === null ) {
85+ if (! isset ($ object ->url )) {
8586 return [];
8687 }
8788
88- $ objUrl = Url::fromPath ($ object ->url );
89-
9089 $ objectUrl = new Link (
9190 $ object ->name ,
92- $ objUrl -> isExternal () ? $ objUrl -> getAbsoluteUrl () : $ objUrl -> getRelativeUrl ( ),
93- ['class ' => ' subject ' , ' data-base-target ' => '_next ' ]
91+ Url:: fromPath ( $ object -> url ),
92+ ['data-base-target ' => '_next ' ]
9493 );
94+ } else {
95+ $ objectUrl = new HtmlElement ('div ' , Attributes::create ([
96+ 'data-base-target ' => '_next ' ,
97+ 'class ' => ['icinga-module ' , 'module- ' . ClassLoader::extractModuleName ($ hook ::class)]
98+ ]), $ objectUrl );
9599 }
96100
97101 return [
@@ -102,7 +106,7 @@ protected function createRelatedObject(): array
102106
103107 protected function createMessage (): array
104108 {
105- $ isEmpty = $ this ->incident ->message === null || $ this -> incident -> message === '' ;
109+ $ isEmpty = empty ( $ this ->incident ->message ) ;
106110 $ message = new HtmlElement (
107111 'div ' ,
108112 Attributes::create ([
0 commit comments