mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
API Removed BigFamilyPage, use FTPageMakerTask instead
This commit is contained in:
parent
a7b2db1e85
commit
848d487051
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
class BigFamilyPage extends Page{
|
||||
public function requireDefaultRecords() {
|
||||
parent::requireDefaultRecords();
|
||||
|
||||
//clear all old records
|
||||
$bigFmailyPages = DB::query("SELECT \"SiteTree_Live\".\"ID\" FROM \"SiteTree_Live\" WHERE \"SiteTree_Live\".\"ClassName\" = 'BigFamilyPage'")->column();
|
||||
if(count($bigFmailyPages)){
|
||||
$ids = "(".implode(",", $bigFmailyPages).")";
|
||||
//Delete all children from all stages
|
||||
DB::query("DELETE FROM \"SiteTree\" WHERE \"SiteTree\".\"ParentID\" IN $ids");
|
||||
DB::query("DELETE FROM \"SiteTree_versions\" WHERE \"SiteTree_versions\".\"ParentID\" IN $ids");
|
||||
DB::query("DELETE FROM \"SiteTree_Live\" WHERE \"SiteTree_Live\".\"ParentID\" IN $ids");
|
||||
|
||||
//Delete themselves from all stages
|
||||
DB::query("DELETE FROM \"SiteTree\" WHERE \"SiteTree\".\"ID\" IN $ids");
|
||||
DB::query("DELETE FROM \"SiteTree_versions\" WHERE \"SiteTree_versions\".\"RecordID\" IN $ids");
|
||||
DB::query("DELETE FROM \"SiteTree_Live\" WHERE \"SiteTree_Live\".\"ID\" IN $ids");
|
||||
}
|
||||
|
||||
//create new records
|
||||
$bigFamilyPages = DataObject::get('BigFamilyPage');
|
||||
foreach ($bigFamilyPages as $page) {
|
||||
foreach($page->AllChildren() as $child){
|
||||
$child->delete();
|
||||
}
|
||||
$page->delete();
|
||||
}
|
||||
|
||||
$familyPage = new BigFamilyPage();
|
||||
$familyPage->Title = "Big Family";
|
||||
$familyPage->write();
|
||||
$familyPage->publish('Stage', 'Live');
|
||||
|
||||
foreach(singleton('Employee')->data() as $name){
|
||||
$page = new Page();
|
||||
$page->Title = $name;
|
||||
$page->MenuTitle = $name;
|
||||
$page->ParentID = $familyPage->ID;
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
}
|
||||
|
||||
DB::alteration_message("Added default 'BigFamilyPage' and its children pages","created");
|
||||
}
|
||||
}
|
||||
|
||||
class BigFamilyPage_Controller extends Page_Controller{
|
||||
}
|
Loading…
Reference in New Issue
Block a user