Skip to content

Commit

Permalink
API Stop using deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Nov 28, 2022
1 parent ceaa915 commit 416f55a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/Extensions/SiteTreeSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ public function onBeforeDuplicate()
*/
public function duplicateToSubsite($subsiteID = null, $includeChildren = false)
{
/** @var SiteTree|SiteTreeSubsites */
$clone = $this->owner->duplicateToSubsitePrep($subsiteID, $includeChildren);
$clone->invokeWithExtensions('onBeforeDuplicateToSubsite', $this->owner);

Expand All @@ -267,12 +268,13 @@ public function duplicateToSubsite($subsiteID = null, $includeChildren = false)
* It may be that some relations are not diostinct to sub site so can stay
* whereas others may need to be duplicated
*
* @deprecated 2.2.0 Use the "cascade_duplicates" config API instead
* This was originally deprecated - Use the "cascade_duplicates" config API instead
* Ideally this would be re-deprecated
*
* @param SiteTree $originalPage
*/
public function duplicateSubsiteRelations($originalPage)
{
Deprecation::notice('2.2.0', 'Use the "cascade_duplicates" config API instead');
$thisClass = $originalPage->ClassName;
$relations = Config::inst()->get($thisClass, 'duplicate_to_subsite_relations');

Expand Down
2 changes: 1 addition & 1 deletion src/Model/Subsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public static function accessible_sites(

// Rationalise member arguments
if (!$member) {
$member = Member::currentUser();
$member = Security::getCurrentUser();
}
if (!$member) {
return new ArrayList();
Expand Down
6 changes: 3 additions & 3 deletions tests/php/LeftAndMainSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ public function testSectionSites()

$cmsmain = singleton(CMSMain::class);
$subsites = $cmsmain->sectionSites(true, 'Main site', $member);
$this->assertDOSEquals([
$this->assertListEquals([
['Title' => 'Subsite1 Template']
], $subsites, 'Lists member-accessible sites for the accessible controller.');

$assetadmin = singleton(AssetAdmin::class);
$subsites = $assetadmin->sectionSites(true, 'Main site', $member);
$this->assertDOSEquals([], $subsites, 'Does not list any sites for forbidden controller.');
$this->assertListEquals([], $subsites, 'Does not list any sites for forbidden controller.');

$member = $this->objFromFixture(Member::class, 'editor');

$cmsmain = singleton(CMSMain::class);
$subsites = $cmsmain->sectionSites(true, 'Main site', $member);
$this->assertDOSContains([
$this->assertListContains([
['Title' => 'Main site']
], $subsites, 'Includes the main site for members who can access all sites.');
}
Expand Down
8 changes: 4 additions & 4 deletions tests/php/SubsiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function domainProtocolProvider()
public function testAllSites()
{
$subsites = Subsite::all_sites();
$this->assertDOSEquals([
$this->assertListEquals([
['Title' => 'Main site'],
['Title' => 'Template'],
['Title' => 'Subsite1 Template'],
Expand All @@ -370,7 +370,7 @@ public function testAllAccessibleSites()
$member = $this->objFromFixture(Member::class, 'subsite1member');

$subsites = Subsite::all_accessible_sites(true, 'Main site', $member);
$this->assertDOSEquals([
$this->assertListEquals([
['Title' => 'Subsite1 Template']
], $subsites, 'Lists member-accessible sites.');
}
Expand Down Expand Up @@ -471,7 +471,7 @@ public function testDuplicateSubsite()
$page1 = new Page();
$page1->Title = 'MyAwesomePage';
$page1->write();
$page1->doPublish();
$page1->publishRecursive();
$this->assertEquals($page1->SubsiteID, $subsite1->ID);

// duplicate
Expand All @@ -481,7 +481,7 @@ public function testDuplicateSubsite()
$page2 = DataObject::get_one('Page', "\"Title\" = 'MyAwesomePage'");
$page2->Title = 'MyNewAwesomePage';
$page2->write();
$page2->doPublish();
$page2->publishRecursive();

// check change & check change has not affected subiste1
$subsite1->activate();
Expand Down

0 comments on commit 416f55a

Please sign in to comment.