Skip to content

Commit

Permalink
fixing code analysis: simplify if-return statements
Browse files Browse the repository at this point in the history
  • Loading branch information
wernerkrauss committed Jun 1, 2017
1 parent fea1684 commit 9673c88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
16 changes: 3 additions & 13 deletions code/extensions/LeftAndMainSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,10 @@ public function alternateMenuDisplayCheck($controllerName)
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,
// which in turn uses the Permission API which is augmented by our GroupSubsites.

return false;
$controller = singleton($controllerName);
return $controller->hasMethod('subsiteCMSShowInMenu') && $controller->subsiteCMSShowInMenu();
}

public function CanAddSubsites()
Expand Down Expand Up @@ -227,12 +222,7 @@ public function canAccess()

// Check if we have access to current section on the current subsite.
$accessibleSites = $this->owner->sectionSites(true, 'Main site', $member);
if ($accessibleSites->count() && $accessibleSites->find('ID', Subsite::currentSubsiteID())) {
// Current section can be accessed on the current site, all good.
return true;
}

return false;
return $accessibleSites->count() && $accessibleSites->find('ID', Subsite::currentSubsiteID());
}

/**
Expand Down
5 changes: 1 addition & 4 deletions code/extensions/SiteTreeSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ class SiteTreeSubsites extends DataExtension

public function isMainSite()
{
if ($this->owner->SubsiteID == 0) {
return true;
}
return false;
return $this->owner->SubsiteID == 0;
}

/**
Expand Down

0 comments on commit 9673c88

Please sign in to comment.