Skip to content

Commit

Permalink
TASK bulk add flowchart pages
Browse files Browse the repository at this point in the history
Make it easier to test the flowchart builder with a large number of
flowchart pages.
  • Loading branch information
Naomi Guyer committed Feb 24, 2014
1 parent 2edd493 commit 562cc58
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions code/tasks/MakePagesTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/*
* Task creates 100 flowchart pages. Useful when testing.
*/
class MakePagesTask extends BuildTask {

public function run($request) {
$masterPage = false;
// Group all pages under a page
$masterPages = Page::get()->filter('Title', 'flowchart-holder');
if($masterPages->count()) {
$masterPage = $masterPages->first();
}
if(!$masterPage) {
$masterPage = new Page();
$masterPage->Title = 'flowchart-holder';
$masterPage->write();
}


$numPages = 100;
for($a=0; $a<$numPages; $a++) {
$randomName = uniqid();
$page = new FlowchartPage();
$page->Title = 'flowchart-'.$randomName;
$page->URLSegment = 'flowchart-'.$randomName;
$page->ParentID = $masterPage->ID;
$page->write();
echo '- '.$page->Title.PHP_EOL;
}
}

}

0 comments on commit 562cc58

Please sign in to comment.