API Stop using deprecated API

This commit is contained in:
Steve Boyd 2022-11-28 17:49:50 +13:00
parent ceaa915b77
commit 416f55ad03
4 changed files with 12 additions and 10 deletions

View File

@ -245,6 +245,7 @@ class SiteTreeSubsites extends DataExtension
*/ */
public function duplicateToSubsite($subsiteID = null, $includeChildren = false) public function duplicateToSubsite($subsiteID = null, $includeChildren = false)
{ {
/** @var SiteTree|SiteTreeSubsites */
$clone = $this->owner->duplicateToSubsitePrep($subsiteID, $includeChildren); $clone = $this->owner->duplicateToSubsitePrep($subsiteID, $includeChildren);
$clone->invokeWithExtensions('onBeforeDuplicateToSubsite', $this->owner); $clone->invokeWithExtensions('onBeforeDuplicateToSubsite', $this->owner);
@ -267,12 +268,13 @@ class SiteTreeSubsites extends DataExtension
* It may be that some relations are not diostinct to sub site so can stay * It may be that some relations are not diostinct to sub site so can stay
* whereas others may need to be duplicated * 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 * @param SiteTree $originalPage
*/ */
public function duplicateSubsiteRelations($originalPage) public function duplicateSubsiteRelations($originalPage)
{ {
Deprecation::notice('2.2.0', 'Use the "cascade_duplicates" config API instead');
$thisClass = $originalPage->ClassName; $thisClass = $originalPage->ClassName;
$relations = Config::inst()->get($thisClass, 'duplicate_to_subsite_relations'); $relations = Config::inst()->get($thisClass, 'duplicate_to_subsite_relations');

View File

@ -448,7 +448,7 @@ class Subsite extends DataObject
// Rationalise member arguments // Rationalise member arguments
if (!$member) { if (!$member) {
$member = Member::currentUser(); $member = Security::getCurrentUser();
} }
if (!$member) { if (!$member) {
return new ArrayList(); return new ArrayList();

View File

@ -38,19 +38,19 @@ class LeftAndMainSubsitesTest extends FunctionalTest
$cmsmain = singleton(CMSMain::class); $cmsmain = singleton(CMSMain::class);
$subsites = $cmsmain->sectionSites(true, 'Main site', $member); $subsites = $cmsmain->sectionSites(true, 'Main site', $member);
$this->assertDOSEquals([ $this->assertListEquals([
['Title' => 'Subsite1 Template'] ['Title' => 'Subsite1 Template']
], $subsites, 'Lists member-accessible sites for the accessible controller.'); ], $subsites, 'Lists member-accessible sites for the accessible controller.');
$assetadmin = singleton(AssetAdmin::class); $assetadmin = singleton(AssetAdmin::class);
$subsites = $assetadmin->sectionSites(true, 'Main site', $member); $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'); $member = $this->objFromFixture(Member::class, 'editor');
$cmsmain = singleton(CMSMain::class); $cmsmain = singleton(CMSMain::class);
$subsites = $cmsmain->sectionSites(true, 'Main site', $member); $subsites = $cmsmain->sectionSites(true, 'Main site', $member);
$this->assertDOSContains([ $this->assertListContains([
['Title' => 'Main site'] ['Title' => 'Main site']
], $subsites, 'Includes the main site for members who can access all sites.'); ], $subsites, 'Includes the main site for members who can access all sites.');
} }

View File

@ -350,7 +350,7 @@ class SubsiteTest extends BaseSubsiteTest
public function testAllSites() public function testAllSites()
{ {
$subsites = Subsite::all_sites(); $subsites = Subsite::all_sites();
$this->assertDOSEquals([ $this->assertListEquals([
['Title' => 'Main site'], ['Title' => 'Main site'],
['Title' => 'Template'], ['Title' => 'Template'],
['Title' => 'Subsite1 Template'], ['Title' => 'Subsite1 Template'],
@ -370,7 +370,7 @@ class SubsiteTest extends BaseSubsiteTest
$member = $this->objFromFixture(Member::class, 'subsite1member'); $member = $this->objFromFixture(Member::class, 'subsite1member');
$subsites = Subsite::all_accessible_sites(true, 'Main site', $member); $subsites = Subsite::all_accessible_sites(true, 'Main site', $member);
$this->assertDOSEquals([ $this->assertListEquals([
['Title' => 'Subsite1 Template'] ['Title' => 'Subsite1 Template']
], $subsites, 'Lists member-accessible sites.'); ], $subsites, 'Lists member-accessible sites.');
} }
@ -471,7 +471,7 @@ class SubsiteTest extends BaseSubsiteTest
$page1 = new Page(); $page1 = new Page();
$page1->Title = 'MyAwesomePage'; $page1->Title = 'MyAwesomePage';
$page1->write(); $page1->write();
$page1->doPublish(); $page1->publishRecursive();
$this->assertEquals($page1->SubsiteID, $subsite1->ID); $this->assertEquals($page1->SubsiteID, $subsite1->ID);
// duplicate // duplicate
@ -481,7 +481,7 @@ class SubsiteTest extends BaseSubsiteTest
$page2 = DataObject::get_one('Page', "\"Title\" = 'MyAwesomePage'"); $page2 = DataObject::get_one('Page', "\"Title\" = 'MyAwesomePage'");
$page2->Title = 'MyNewAwesomePage'; $page2->Title = 'MyNewAwesomePage';
$page2->write(); $page2->write();
$page2->doPublish(); $page2->publishRecursive();
// check change & check change has not affected subiste1 // check change & check change has not affected subiste1
$subsite1->activate(); $subsite1->activate();