From 2778d1166ea5b6ed953066d9c6edc496e7566ace Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Fri, 22 Nov 2024 02:27:08 +0300 Subject: [PATCH] Bugfix main 8333 fix menu item nullability (#10619) * pkp/pkp-lib#8333 Fixed contextId nullability for the NavigationMenuItem * pkp/pkp-lib#8333 Fixed type of getUrl()/setUrl() --- classes/navigationMenu/NavigationMenuItem.php | 4 ++-- .../navigationMenus/form/NavigationMenuForm.php | 14 +------------- .../form/PKPNavigationMenuItemsForm.php | 9 +++------ 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/classes/navigationMenu/NavigationMenuItem.php b/classes/navigationMenu/NavigationMenuItem.php index 0bdc562542e..f5391b121a9 100755 --- a/classes/navigationMenu/NavigationMenuItem.php +++ b/classes/navigationMenu/NavigationMenuItem.php @@ -66,7 +66,7 @@ public function getPath(): ?string /** * Set url for this navigation menu item. */ - public function setUrl(string $url): void + public function setUrl(?string $url): void { $this->setData('url', $url); } @@ -74,7 +74,7 @@ public function setUrl(string $url): void /** * Get url for this navigation menu item. */ - public function getUrl(): string + public function getUrl(): ?string { return $this->getData('url'); } diff --git a/controllers/grid/navigationMenus/form/NavigationMenuForm.php b/controllers/grid/navigationMenus/form/NavigationMenuForm.php index 20606216477..4dcd669faea 100644 --- a/controllers/grid/navigationMenus/form/NavigationMenuForm.php +++ b/controllers/grid/navigationMenus/form/NavigationMenuForm.php @@ -29,23 +29,11 @@ class NavigationMenuForm extends Form { - /** @var int Context ID */ - public $_contextId; - - /** @var int $_navigationMenuId The menu id being edited */ - public $_navigationMenuId; - /** * Constructor - * - * @param int $contextId Context ID - * @param int $navigationMenuId NavigationMenu Id */ - public function __construct(int $contextId, $navigationMenuId = null) + public function __construct(public ?int $_contextId, public ?int $_navigationMenuId = null) { - $this->_navigationMenuId = !empty($navigationMenuId) ? (int) $navigationMenuId : null; - $this->_contextId = $contextId; - parent::__construct('controllers/grid/navigationMenus/form/navigationMenuForm.tpl'); $this->addCheck(new \PKP\form\validation\FormValidator($this, 'title', 'required', 'manager.navigationMenus.form.titleRequired')); diff --git a/controllers/grid/navigationMenus/form/PKPNavigationMenuItemsForm.php b/controllers/grid/navigationMenus/form/PKPNavigationMenuItemsForm.php index 3fa0dac1652..112e99782eb 100755 --- a/controllers/grid/navigationMenus/form/PKPNavigationMenuItemsForm.php +++ b/controllers/grid/navigationMenus/form/PKPNavigationMenuItemsForm.php @@ -28,8 +28,7 @@ class PKPNavigationMenuItemsForm extends Form /** @var int $navigationMenuItemId the ID of the navigationMenuItem */ public $navigationMenuItemId; - /** @var int */ - public $_contextId; + public ?int $_contextId; /** * Constructor @@ -37,7 +36,7 @@ class PKPNavigationMenuItemsForm extends Form * @param int $contextId * @param int $navigationMenuItemId */ - public function __construct(int $contextId, $navigationMenuItemId) + public function __construct(?int $contextId, $navigationMenuItemId) { $this->_contextId = $contextId; $this->navigationMenuItemId = $navigationMenuItemId; @@ -55,10 +54,8 @@ public function __construct(int $contextId, $navigationMenuItemId) /** * Get the current context id. - * - * @return int */ - public function getContextId() + public function getContextId(): ?int { return $this->_contextId; }