fixing code analysis: simplify if-return statements

This commit is contained in:
Werner M. Krauß 2017-06-01 15:48:01 +02:00
parent fea1684f5c
commit 9673c881c1
2 changed files with 4 additions and 17 deletions

View File

@ -176,15 +176,10 @@ class LeftAndMainSubsites extends Extension
return true; return true;
} }
$controller = singleton($controllerName);
if ($controller->hasMethod('subsiteCMSShowInMenu') && $controller->subsiteCMSShowInMenu()) {
return true;
}
// It's not necessary to check access permissions here. Framework calls canView on the controller, // It's not necessary to check access permissions here. Framework calls canView on the controller,
// which in turn uses the Permission API which is augmented by our GroupSubsites. // which in turn uses the Permission API which is augmented by our GroupSubsites.
$controller = singleton($controllerName);
return false; return $controller->hasMethod('subsiteCMSShowInMenu') && $controller->subsiteCMSShowInMenu();
} }
public function CanAddSubsites() public function CanAddSubsites()
@ -227,12 +222,7 @@ class LeftAndMainSubsites extends Extension
// Check if we have access to current section on the current subsite. // Check if we have access to current section on the current subsite.
$accessibleSites = $this->owner->sectionSites(true, 'Main site', $member); $accessibleSites = $this->owner->sectionSites(true, 'Main site', $member);
if ($accessibleSites->count() && $accessibleSites->find('ID', Subsite::currentSubsiteID())) { return $accessibleSites->count() && $accessibleSites->find('ID', Subsite::currentSubsiteID());
// Current section can be accessed on the current site, all good.
return true;
}
return false;
} }
/** /**

View File

@ -45,10 +45,7 @@ class SiteTreeSubsites extends DataExtension
public function isMainSite() public function isMainSite()
{ {
if ($this->owner->SubsiteID == 0) { return $this->owner->SubsiteID == 0;
return true;
}
return false;
} }
/** /**