silverstripe-frameworktest/code/FTPageMakerTask.php

37 lines
898 B
PHP
Raw Normal View History

2012-02-29 15:49:37 +01:00
<?php
use SilverStripe\Dev\BuildTask;
2012-02-29 15:49:37 +01:00
/**
* Creates sample page structure, useful to test tree performance,
* UI behaviour on deeply nested pages etc.
*
* @todo Allow passing in counts
*/
2015-12-17 21:20:49 +01:00
class FTPageMakerTask extends BuildTask
{
2012-02-29 15:49:37 +01:00
2015-12-17 21:20:49 +01:00
public function run($request)
{
echo "<h1>Making pages</h1>";
// Creates 3^5 pages
$this->makePages(3, 5);
}
protected function makePages($count, $depth, $prefix = "", $parentID = 0)
{
for ($i=1;$i<=$count;$i++) {
$page = new Page();
$page->ParentID = $parentID;
$page->Title = "Test page $prefix$i";
$page->write();
$page->publish('Stage', 'Live');
2012-02-29 15:49:37 +01:00
2015-12-17 21:20:49 +01:00
echo "<li>Created '$page->Title'";
if ($depth > 1) {
$this->makePages($count, $depth-1, $prefix."$i.", $page->ID);
}
}
}
}