Skip to content

Commit

Permalink
Merge pull request #206 from xini/fix-page-history
Browse files Browse the repository at this point in the history
fix page history: remove DMSSiteTreeExtension.getDocumentSets()
  • Loading branch information
NightJar authored Apr 11, 2018
2 parents fb6bdf5 + 1c22623 commit fad86bd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion code/DMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function getByPage(SiteTree $page, $showEmbargoed = false)

public function getDocumentSetsByPage(SiteTree $page)
{
return $page->getDocumentSets();
return $page->DocumentSets();
}

/**
Expand Down
7 changes: 5 additions & 2 deletions code/extensions/DMSSiteTreeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ public function updateCMSFields(FieldList $fields)
/**
* Get a list of document sets for the owner page
*
* @deprecated 3.0 Use DocumentSets() instead.
*
* @return ArrayList
*/
public function getDocumentSets()
{
return $this->owner->DocumentSets();
Deprecation::notice('3.0', 'Use DocumentSets() instead');
return $this->owner->hasManyComponent('DocumentSets');
}

/**
Expand All @@ -71,7 +74,7 @@ public function getAllDocuments()
{
$documents = ArrayList::create();

foreach ($this->getDocumentSets() as $documentSet) {
foreach ($this->owner->DocumentSets() as $documentSet) {
/** @var DocumentSet $documentSet */
$documents->merge($documentSet->getDocuments());
}
Expand Down
4 changes: 2 additions & 2 deletions templates/Includes/DocumentSets.ss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if $getDocumentSets %>
<% if $DocumentSets %>
<div class="documentsets">
<% loop $getDocumentSets %>
<% loop $DocumentSets %>
<% include DocumentSet %>
<% end_loop %>
</div>
Expand Down
6 changes: 3 additions & 3 deletions tests/DMSDocumentSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function testRelations()
$ds2 = $this->objFromFixture('DMSDocumentSet', 'ds2');
$ds3 = $this->objFromFixture('DMSDocumentSet', 'ds3');

$this->assertCount(0, $s4->getDocumentSets(), 'Page 4 has no document sets associated');
$this->assertCount(2, $s1->getDocumentSets(), 'Page 1 has 2 document sets');
$this->assertEquals(array($ds1->ID, $ds2->ID), $s1->getDocumentSets()->column('ID'));
$this->assertCount(0, $s4->DocumentSets(), 'Page 4 has no document sets associated');
$this->assertCount(2, $s1->DocumentSets(), 'Page 1 has 2 document sets');
$this->assertEquals(array($ds1->ID, $ds2->ID), $s1->DocumentSets()->column('ID'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/DMSEmbargoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function testEmbargoUntilPublished()
$doc->Folder = "0";
$dID = $doc->write();

$s1->getDocumentSets()->first()->getDocuments()->add($doc);
$s1->DocumentSets()->first()->getDocuments()->add($doc);

$s1->publish('Stage', 'Live');
$s1->doPublish();
Expand Down
4 changes: 2 additions & 2 deletions tests/tasks/MigrateToDocumentSetsTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public function testCreateDefaultDocumentSets()
$this->assertContains('Skipped: already has a set: 1', $result);

// Test that some of the relationship records were written correctly
$this->assertCount(1, $firstPageSets = $this->objFromFixture('SiteTree', 'one')->getDocumentSets());
$this->assertCount(1, $firstPageSets = $this->objFromFixture('SiteTree', 'one')->DocumentSets());
$this->assertSame('Default', $firstPageSets->first()->Title);
$this->assertCount(1, $this->objFromFixture('SiteTree', 'two')->getDocumentSets());
$this->assertCount(1, $this->objFromFixture('SiteTree', 'two')->DocumentSets());

// With dryrun enabled and being run the second time, nothing should be done
$result = $this->runTask(array('action' => 'create-default-document-set', 'dryrun' => '1'));
Expand Down

0 comments on commit fad86bd

Please sign in to comment.