Skip to content

Commit

Permalink
ENH Stop using Controller::has_curr()
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Feb 13, 2025
1 parent 683c1bf commit f6e01f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions code/AdminErrorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ private function getAdminController(): ?Controller
if ($this->owner instanceof LeftAndMain) {
return $this->owner;
}
if (Controller::has_curr() && (Controller::curr() instanceof LeftAndMain)) {
return Controller::curr();
$controller = Controller::curr();
if ($controller instanceof LeftAndMain) {
return $controller;
}
return null;
}
Expand Down
5 changes: 3 additions & 2 deletions code/CMSMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,11 @@ public static function get_viewable_menu_items($member = null)
// checks on
if ($menuItem->controller) {
$controllerObj = singleton($menuItem->controller);
if (Controller::has_curr()) {
$controllerCurr = Controller::curr();
if ($controllerCurr) {
// Necessary for canView() to have request data available,
// e.g. to check permissions against LeftAndMain->currentRecord()
$controllerObj->setRequest(Controller::curr()->getRequest());
$controllerObj->setRequest($controllerCurr->getRequest());
if (!$controllerObj->canView($member)) {
continue;
}
Expand Down

0 comments on commit f6e01f4

Please sign in to comment.