Skip to content

Commit

Permalink
FIX Update alternateTreeTitle to updateTreeTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Aug 29, 2017
1 parent e129caf commit 3803188
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
18 changes: 9 additions & 9 deletions code/extensions/GroupSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,20 @@ public function updateCMSFields(FieldList $fields)
}

/**
* If this group belongs to a subsite,
* append the subsites title to the group title
* to make it easy to distinguish in the tree-view
* of the security admin interface.
* If this group belongs to a subsite, append the subsites title to the group title to make it easy to
* distinguish in the tree-view of the security admin interface.
*
* @param string $title
*/
public function alternateTreeTitle()
public function updateTreeTitle(&$title)
{
if ($this->owner->AccessAllSubsites) {
$title = _t('GroupSubsites.GlobalGroup', 'global group');
return htmlspecialchars($this->owner->Title, ENT_QUOTES) . ' <i>(' . $title . ')</i>';
$title = htmlspecialchars($this->owner->Title, ENT_QUOTES) . ' <i>(' . $title . ')</i>';
} else {
$subsites = Convert::raw2xml(implode(', ', $this->owner->Subsites()->column('Title')));
$title = htmlspecialchars($this->owner->Title) . " <i>($subsites)</i>";
}

$subsites = Convert::raw2xml(implode(', ', $this->owner->Subsites()->column('Title')));
return htmlspecialchars($this->owner->Title) . " <i>($subsites)</i>";
}

/**
Expand Down
10 changes: 6 additions & 4 deletions tests/php/GroupSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class GroupSubsitesTest extends BaseSubsiteTest

public function testTrivialFeatures()
{
$this->assertTrue(is_array(singleton(GroupSubsites::class)->extraStatics()));
$this->assertTrue(is_array(singleton(GroupSubsites::class)->providePermissions()));
$this->assertInternalType('array', singleton(GroupSubsites::class)->extraStatics());
$this->assertInternalType('array', singleton(GroupSubsites::class)->providePermissions());
$this->assertInstanceOf(FieldList::class, singleton(Group::class)->getCMSFields());
}

Expand All @@ -25,11 +25,13 @@ public function testAlternateTreeTitle()
$group = new Group();
$group->Title = 'The A Team';
$group->AccessAllSubsites = true;
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(global group)</i>');
$this->assertEquals('The A Team <i>(global group)</i>', $group->getTreeTitle());

$group->AccessAllSubsites = false;
$group->write();

$group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest1'));
$group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest2'));
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(Test 1, Test 2)</i>');
$this->assertEquals('The A Team <i>(Test 1, Test 2)</i>', $group->getTreeTitle());
}
}

0 comments on commit 3803188

Please sign in to comment.