Permalink
Browse files

MINOR refactored setting/getting strict hierarchy setting. (from r986…

…54) (from r99064)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102832 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 809072d commit 000d892256b57f4d293eae7193da3a01e35ecbe4 @chillu chillu committed Apr 14, 2010
Showing with 12 additions and 16 deletions.
  1. +6 −10 core/model/SiteTree.php
  2. +6 −6 tests/SiteTreeTest.php
View
16 core/model/SiteTree.php
@@ -198,15 +198,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
*/
private static $enforce_strict_hierarchy = true;
- /**
- * Getter and setter for enforce_strict_hierarchy. With no
- * args it returns current value. Pass arg to set.
- *
- * @return bool
- */
- public static function enforce_strict_hierarchy() {
- $args = func_get_args();
- if (count($args)) self::$enforce_strict_hierarchy = (bool) $args[0];
+ public static function set_enforce_strict_hierarchy($to) {
+ self::$enforce_strict_hierarchy = $to;
+ }
+
+ public static function get_enforce_strict_hierarchy() {
return self::$enforce_strict_hierarchy;
}
@@ -1420,7 +1416,7 @@ function onBeforeDelete() {
parent::onBeforeDelete();
// If deleting this page, delete all its children.
- if(SiteTree::enforce_strict_hierarchy() && $children = $this->Children()) {
+ if(SiteTree::get_enforce_strict_hierarchy() && $children = $this->Children()) {
foreach($children as $child) {
$child->delete();
}
View
12 tests/SiteTreeTest.php
@@ -307,7 +307,7 @@ public function testGetByLink() {
}
function testDeleteFromStageOperatesRecursively() {
- SiteTree::enforce_strict_hierarchy(false);
+ SiteTree::set_enforce_strict_hierarchy(false);
$pageAbout = $this->objFromFixture('Page', 'about');
$pageStaff = $this->objFromFixture('Page', 'staff');
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
@@ -317,7 +317,7 @@ function testDeleteFromStageOperatesRecursively() {
$this->assertFalse(DataObject::get_by_id('Page', $pageAbout->ID));
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
- SiteTree::enforce_strict_hierarchy(true);
+ SiteTree::set_enforce_strict_hierarchy(true);
}
function testDeleteFromStageOperatesRecursivelyStrict() {
@@ -333,7 +333,7 @@ function testDeleteFromStageOperatesRecursivelyStrict() {
}
function testDeleteFromLiveOperatesRecursively() {
- SiteTree::enforce_strict_hierarchy(false);
+ SiteTree::set_enforce_strict_hierarchy(false);
$this->logInWithPermssion('ADMIN');
$pageAbout = $this->objFromFixture('Page', 'about');
@@ -351,11 +351,11 @@ function testDeleteFromLiveOperatesRecursively() {
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
Versioned::reading_stage('Stage');
- SiteTree::enforce_strict_hierarchy(true);
+ SiteTree::set_enforce_strict_hierarchy(true);
}
function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn() {
- SiteTree::enforce_strict_hierarchy(false);
+ SiteTree::set_enforce_strict_hierarchy(false);
$this->logInWithPermssion('ADMIN');
$pageAbout = $this->objFromFixture('Page', 'about');
@@ -373,7 +373,7 @@ function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn() {
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
Versioned::reading_stage('Stage');
- SiteTree::enforce_strict_hierarchy(true);
+ SiteTree::set_enforce_strict_hierarchy(true);
}

0 comments on commit 000d892

Please sign in to comment.