@@ -121,16 +121,14 @@ public function getIconForTag(): string
121121 return 'tag ' ;
122122 }
123123
124- public function getIconForClassDefinition (?string $ iconPath ): ElementIcon
124+ public function getIconForClassDefinition (?string $ value ): ElementIcon
125125 {
126- $ type = ElementIconTypes::PATH ->value ;
127126 // $iconPath can be null and empty string
128- if (empty ($ iconPath )) {
129- $ type = ElementIconTypes::NAME ->value ;
130- $ iconPath = 'class ' ;
127+ if (empty ($ value )) {
128+ return new ElementIcon (ElementIconTypes::NAME ->value , 'class ' );
131129 }
132130
133- return new ElementIcon ($ type , $ iconPath );
131+ return new ElementIcon ($ this -> guessIconType ( $ value ) , $ value );
134132 }
135133
136134 public function getIconForLayout (?string $ iconPath ): ?ElementIcon
@@ -157,14 +155,26 @@ private function getClassIcon(DataObjectSearchResultItem|DataObject $dataObject)
157155 if ($ dataObject instanceof Concrete) {
158156 $ class = $ this ->getValidClass ($ this ->classDefinitionResolver , $ dataObject ->getClassId ());
159157 if ($ class ->getIcon () !== null ) {
160- return new ElementIcon (ElementIconTypes:: PATH -> value , $ class ->getIcon ());
158+ return new ElementIcon ($ this -> guessIconType ( $ class -> getIcon ()) , $ class ->getIcon ());
161159 }
162160 }
163161
164162 if ($ dataObject ->getClassDefinitionIcon () !== null ) {
165- return new ElementIcon (ElementIconTypes::PATH ->value , $ dataObject ->getClassDefinitionIcon ());
163+ return new ElementIcon (
164+ $ this ->guessIconType ($ dataObject ->getClassDefinitionIcon ()),
165+ $ dataObject ->getClassDefinitionIcon ()
166+ );
166167 }
167168
168169 return null ;
169170 }
171+
172+ private function guessIconType (string $ value ): string
173+ {
174+ if (str_contains ($ value , '/ ' ) && str_contains ($ value , '. ' )) {
175+ return ElementIconTypes::PATH ->value ;
176+ }
177+
178+ return ElementIconTypes::NAME ->value ;
179+ }
170180}
0 commit comments