Skip to content

Commit

Permalink
Bugfix main 8333 fix menu item nullability (#10619)
Browse files Browse the repository at this point in the history
* #8333 Fixed contextId nullability for the NavigationMenuItem

* #8333 Fixed type of getUrl()/setUrl()
  • Loading branch information
jonasraoni authored Nov 21, 2024
1 parent 4e8a5a1 commit 6729bd3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
4 changes: 2 additions & 2 deletions classes/navigationMenu/NavigationMenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ 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);
}

/**
* Get url for this navigation menu item.
*/
public function getUrl(): string
public function getUrl(): ?string
{
return $this->getData('url');
}
Expand Down
14 changes: 1 addition & 13 deletions controllers/grid/navigationMenus/form/NavigationMenuForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ class PKPNavigationMenuItemsForm extends Form
/** @var int $navigationMenuItemId the ID of the navigationMenuItem */
public $navigationMenuItemId;

/** @var int */
public $_contextId;
public ?int $_contextId;

/**
* Constructor
*
* @param int $contextId
* @param int $navigationMenuItemId
*/
public function __construct(int $contextId, $navigationMenuItemId)
public function __construct(?int $contextId, $navigationMenuItemId)
{
$this->_contextId = $contextId;
$this->navigationMenuItemId = $navigationMenuItemId;
Expand All @@ -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;
}
Expand Down

0 comments on commit 6729bd3

Please sign in to comment.