Simplify the logic to determine the icon of a user menu item
authorAlexander Ebert <ebert@woltlab.com>
Wed, 20 Sep 2023 13:13:27 +0000 (15:13 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 20 Sep 2023 13:13:27 +0000 (15:13 +0200)
wcfsetup/install/files/lib/data/user/menu/item/UserMenuItem.class.php
wcfsetup/install/files/lib/data/user/menu/item/event/UserMenuItemIconResolving.class.php

index e495ed33a46044db5ec35ffa4d0e50fe761a205a..0ecb521f4f4764f8c851a90502259fc6cbea55e7 100644 (file)
@@ -155,15 +155,16 @@ class UserMenuItem extends ProcessibleDatabaseObject implements ITitledObject, I
      */
     public function getIcon(): ?IFontAwesomeIcon
     {
-        $icon = null;
         if ($this->iconClassName && !\str_starts_with($this->iconClassName, 'fa-')) {
             $icon = FontAwesomeIcon::fromString($this->iconClassName);
+        } else {
+            $icon = FontAwesomeIcon::fromValues('bars');
         }
 
         $event = new UserMenuItemIconResolving($this);
         $event->icon = $icon;
         EventHandler::getInstance()->fire($event);
 
-        return $event->icon ?: FontAwesomeIcon::fromValues('bars');
+        return $event->icon;
     }
 }
index 72f702c0eb5c8aeccca5c7a40066022d2fcebc4b..5a811460db72ac143b1b0b0e1ec81f5d3e6d8051 100644 (file)
@@ -16,7 +16,7 @@ use wcf\system\style\IFontAwesomeIcon;
  */
 final class UserMenuItemIconResolving implements IEvent
 {
-    public ?IFontAwesomeIcon $icon = null;
+    public IFontAwesomeIcon $icon;
 
     public function __construct(public readonly UserMenuItem $userMenuItem)
     {