mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Remove irrelevant check for subsites list size, use func_num_args() and add break to loop
This commit is contained in:
parent
6af985420f
commit
7681634cb2
@ -88,11 +88,6 @@ class LeftAndMainSubsites extends LeftAndMainExtension
|
||||
$accessibleSubsites = ArrayList::create();
|
||||
$subsites = Subsite::all_sites($includeMainSite, $mainSiteTitle);
|
||||
|
||||
// Check whether we have any subsites
|
||||
if (!$subsites->exists()) {
|
||||
return $accessibleSubsites;
|
||||
}
|
||||
|
||||
foreach ($subsites as $subsite) {
|
||||
/** @var Subsite $subsite */
|
||||
$canAccess = SubsiteState::singleton()
|
||||
@ -211,7 +206,7 @@ class LeftAndMainSubsites extends LeftAndMainExtension
|
||||
public function canAccess()
|
||||
{
|
||||
// Allow us to accept a Member object passed in as an argument without breaking semver
|
||||
$passedMember = func_get_args() ? func_get_arg(0) : null;
|
||||
$passedMember = func_num_args() ? func_get_arg(0) : null;
|
||||
|
||||
// Admin can access everything, no point in checking.
|
||||
$member = $passedMember ?: Security::getCurrentUser();
|
||||
@ -249,6 +244,7 @@ class LeftAndMainSubsites extends LeftAndMainExtension
|
||||
$groupSubsiteIds = $group->Subsites()->column('ID');
|
||||
if (in_array($currentSubsiteId, $groupSubsiteIds)) {
|
||||
$allowedInSubsite = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user