Revert "fix page history: remove DMSSiteTreeExtension.getDocumentSets()"

This commit is contained in:
Dylan Wagstaff 2018-04-11 14:10:55 +12:00 committed by GitHub
parent fad86bd93c
commit 95d37b282d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 14 deletions

View File

@ -151,7 +151,7 @@ class DMS extends Object implements DMSInterface
public function getDocumentSetsByPage(SiteTree $page) public function getDocumentSetsByPage(SiteTree $page)
{ {
return $page->DocumentSets(); return $page->getDocumentSets();
} }
/** /**

View File

@ -55,14 +55,11 @@ class DMSSiteTreeExtension extends DataExtension
/** /**
* Get a list of document sets for the owner page * Get a list of document sets for the owner page
* *
* @deprecated 3.0 Use DocumentSets() instead.
*
* @return ArrayList * @return ArrayList
*/ */
public function getDocumentSets() public function getDocumentSets()
{ {
Deprecation::notice('3.0', 'Use DocumentSets() instead'); return $this->owner->DocumentSets();
return $this->owner->hasManyComponent('DocumentSets');
} }
/** /**
@ -74,7 +71,7 @@ class DMSSiteTreeExtension extends DataExtension
{ {
$documents = ArrayList::create(); $documents = ArrayList::create();
foreach ($this->owner->DocumentSets() as $documentSet) { foreach ($this->getDocumentSets() as $documentSet) {
/** @var DocumentSet $documentSet */ /** @var DocumentSet $documentSet */
$documents->merge($documentSet->getDocuments()); $documents->merge($documentSet->getDocuments());
} }

View File

@ -1,6 +1,6 @@
<% if $DocumentSets %> <% if $getDocumentSets %>
<div class="documentsets"> <div class="documentsets">
<% loop $DocumentSets %> <% loop $getDocumentSets %>
<% include DocumentSet %> <% include DocumentSet %>
<% end_loop %> <% end_loop %>
</div> </div>

View File

@ -50,9 +50,9 @@ class DMSDocumentSetTest extends SapphireTest
$ds2 = $this->objFromFixture('DMSDocumentSet', 'ds2'); $ds2 = $this->objFromFixture('DMSDocumentSet', 'ds2');
$ds3 = $this->objFromFixture('DMSDocumentSet', 'ds3'); $ds3 = $this->objFromFixture('DMSDocumentSet', 'ds3');
$this->assertCount(0, $s4->DocumentSets(), 'Page 4 has no document sets associated'); $this->assertCount(0, $s4->getDocumentSets(), 'Page 4 has no document sets associated');
$this->assertCount(2, $s1->DocumentSets(), 'Page 1 has 2 document sets'); $this->assertCount(2, $s1->getDocumentSets(), 'Page 1 has 2 document sets');
$this->assertEquals(array($ds1->ID, $ds2->ID), $s1->DocumentSets()->column('ID')); $this->assertEquals(array($ds1->ID, $ds2->ID), $s1->getDocumentSets()->column('ID'));
} }
/** /**

View File

@ -142,7 +142,7 @@ class DMSEmbargoTest extends SapphireTest
$doc->Folder = "0"; $doc->Folder = "0";
$dID = $doc->write(); $dID = $doc->write();
$s1->DocumentSets()->first()->getDocuments()->add($doc); $s1->getDocumentSets()->first()->getDocuments()->add($doc);
$s1->publish('Stage', 'Live'); $s1->publish('Stage', 'Live');
$s1->doPublish(); $s1->doPublish();

View File

@ -65,9 +65,9 @@ class MigrateToDocumentSetsTaskTest extends SapphireTest
$this->assertContains('Skipped: already has a set: 1', $result); $this->assertContains('Skipped: already has a set: 1', $result);
// Test that some of the relationship records were written correctly // Test that some of the relationship records were written correctly
$this->assertCount(1, $firstPageSets = $this->objFromFixture('SiteTree', 'one')->DocumentSets()); $this->assertCount(1, $firstPageSets = $this->objFromFixture('SiteTree', 'one')->getDocumentSets());
$this->assertSame('Default', $firstPageSets->first()->Title); $this->assertSame('Default', $firstPageSets->first()->Title);
$this->assertCount(1, $this->objFromFixture('SiteTree', 'two')->DocumentSets()); $this->assertCount(1, $this->objFromFixture('SiteTree', 'two')->getDocumentSets());
// With dryrun enabled and being run the second time, nothing should be done // With dryrun enabled and being run the second time, nothing should be done
$result = $this->runTask(array('action' => 'create-default-document-set', 'dryrun' => '1')); $result = $this->runTask(array('action' => 'create-default-document-set', 'dryrun' => '1'));