mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 09:06:02 +00:00
MINOR Isolated page making as task
This commit is contained in:
parent
4506eba6cb
commit
e34b857b78
29
code/FTPageMakerTask.php
Normal file
29
code/FTPageMakerTask.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Creates sample page structure, useful to test tree performance,
|
||||||
|
* UI behaviour on deeply nested pages etc.
|
||||||
|
*
|
||||||
|
* @todo Allow passing in counts
|
||||||
|
*/
|
||||||
|
class FTPageMakerTask extends BuildTask {
|
||||||
|
|
||||||
|
|
||||||
|
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->doPublish();
|
||||||
|
|
||||||
|
echo "<li>Created '$page->Title'";
|
||||||
|
if($depth > 1) $this->makePages($count, $depth-1, $prefix."$i.", $page->ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,6 @@ class TestPage extends Page {
|
|||||||
*/
|
*/
|
||||||
class TestPage_Controller extends Page_Controller {
|
class TestPage_Controller extends Page_Controller {
|
||||||
static $allowed_actions = array(
|
static $allowed_actions = array(
|
||||||
'makelotsofpages',
|
|
||||||
'Form',
|
'Form',
|
||||||
'save',
|
'save',
|
||||||
);
|
);
|
||||||
@ -60,27 +59,6 @@ class TestPage_Controller extends Page_Controller {
|
|||||||
Director::redirect("./");
|
Director::redirect("./");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a bunch of pages
|
|
||||||
*/
|
|
||||||
function makelotsofpages() {
|
|
||||||
echo "<h1>Making pages</h1>";
|
|
||||||
$this->makePages(5,5);
|
|
||||||
}
|
|
||||||
|
|
||||||
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->doPublish();
|
|
||||||
|
|
||||||
echo "<li>Created '$page->Title'";
|
|
||||||
if($depth > 1) $this->makePages($count, $depth-1, $prefix."$i.", $page->ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function EmailForm() {
|
function EmailForm() {
|
||||||
return new Form($this, "EmailForm", new FieldSet(
|
return new Form($this, "EmailForm", new FieldSet(
|
||||||
new TextField("Email", "Email address")
|
new TextField("Email", "Email address")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user