mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Reverted Hierarchy::extraDBFields() because it interfered with normal generation of the site hierarchy. Note that children(), stageChildren(), and liveChildren() cannot be simply labelled as relations because they are methods with a different semantic meaning. I recommend the use of something similar to to enable access to information beyond relations via the data formatters
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60442 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
62d90957eb
commit
8bf5c3781e
@ -18,16 +18,6 @@ class Hierarchy extends DataObjectDecorator {
|
|||||||
function augmentWrite(&$manipulation) {
|
function augmentWrite(&$manipulation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function extraDbFields() {
|
|
||||||
return array(
|
|
||||||
'has_many' => array(
|
|
||||||
'Children' => 'SiteTree',
|
|
||||||
'StageChildren' => 'SiteTree',
|
|
||||||
'LiveChildren' => 'SiteTree',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the children of this DataObject as an XHTML UL. This will be called recursively on each child,
|
* Returns the children of this DataObject as an XHTML UL. This will be called recursively on each child,
|
||||||
* so if they have children they will be displayed as a UL inside a LI.
|
* so if they have children they will be displayed as a UL inside a LI.
|
||||||
|
@ -80,9 +80,30 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$this->assertEquals("V1", $checkSiteTree->Title);
|
$this->assertEquals("V1", $checkSiteTree->Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function testChidrenOfRootAreTopLevelPages() {
|
||||||
* Test that saving changes creates a new version with the correct data in it.
|
$pages = DataObject::get("SiteTree");
|
||||||
*/
|
foreach($pages as $page) $page->publish('Stage', 'Live');
|
||||||
|
unset($pages);
|
||||||
|
|
||||||
|
/* If we create a new SiteTree object with ID = 0 */
|
||||||
|
$obj = new SiteTree();
|
||||||
|
/* Then its children should be the top-level pages */
|
||||||
|
$stageChildren = $obj->stageChildren()->toDropDownMap('ID','Title');
|
||||||
|
$liveChildren = $obj->liveChildren()->toDropDownMap('ID','Title');
|
||||||
|
$allChildren = $obj->AllChildrenIncludingDeleted()->toDropDownMap('ID','Title');
|
||||||
|
|
||||||
|
$this->assertContains('Home', $stageChildren);
|
||||||
|
$this->assertContains('Products', $stageChildren);
|
||||||
|
$this->assertNotContains('Staff', $stageChildren);
|
||||||
|
|
||||||
|
$this->assertContains('Home', $liveChildren);
|
||||||
|
$this->assertContains('Products', $liveChildren);
|
||||||
|
$this->assertNotContains('Staff', $liveChildren);
|
||||||
|
|
||||||
|
$this->assertContains('Home', $allChildren);
|
||||||
|
$this->assertContains('Products', $allChildren);
|
||||||
|
$this->assertNotContains('Staff', $allChildren);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user