3 namespace wcf\data\user\profile\menu\item
;
5 use wcf\data\DatabaseObject
;
6 use wcf\data\TDatabaseObjectOptions
;
7 use wcf\data\TDatabaseObjectPermissions
;
8 use wcf\system\exception\ClassNotFoundException
;
9 use wcf\system\exception\ImplementationException
;
10 use wcf\system\exception\ParentClassException
;
11 use wcf\system\exception\SystemException
;
12 use wcf\system\menu\user\profile\content\IUserProfileMenuContent
;
13 use wcf\system\SingletonFactory
;
17 * Represents a user profile menu item.
19 * @author Alexander Ebert
20 * @copyright 2001-2019 WoltLab GmbH
21 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
23 * @property-read int $menuItemID unique id of the user profile menu item
24 * @property-read int $packageID id of the package which delivers the user profile menu item
25 * @property-read string $menuItem textual identifier of the user profile menu item
26 * @property-read int $showOrder position of the user profile menu item in relation to its siblings
27 * @property-read string $permissions comma separated list of user group permissions of which the active user needs to have at least one to see the user profile menu item
28 * @property-read string $options comma separated list of options of which at least one needs to be enabled for the user profile menu item to be shown
29 * @property-read string $className name of the PHP class implementing `wcf\system\menu\user\profile\content\IUserProfileMenuContent` handling outputting the content of the user profile tab
31 class UserProfileMenuItem
extends DatabaseObject
33 use TDatabaseObjectOptions
;
34 use TDatabaseObjectPermissions
;
38 * @var IUserProfileMenuContent
40 protected $contentManager;
45 protected static $databaseTableIndexName = 'menuItemID';
48 * Returns the item identifier, dots are replaced by underscores.
52 public function getIdentifier()
54 return \
str_replace('.', '_', $this->menuItem
);
58 * Returns the content manager for this menu item.
60 * @return IUserProfileMenuContent
61 * @throws SystemException
63 public function getContentManager()
65 if ($this->contentManager
=== null) {
66 if (!\
class_exists($this->className
)) {
67 throw new ClassNotFoundException($this->className
);
70 if (!\
is_subclass_of($this->className
, SingletonFactory
::class)) {
71 throw new ParentClassException($this->className
, SingletonFactory
::class);
74 if (!\
is_subclass_of($this->className
, IUserProfileMenuContent
::class)) {
75 throw new ImplementationException($this->className
, IUserProfileMenuContent
::class);
78 $this->contentManager
= \
call_user_func([$this->className
, 'getInstance']);
81 return $this->contentManager
;
84 public function __toString(): string
86 return WCF
::getLanguage()->get('wcf.user.profile.menu.' . $this->menuItem
);