mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
parent
db7c537666
commit
7fcf623639
@ -11,10 +11,8 @@ use SilverStripe\Forms\FieldList;
|
|||||||
use SilverStripe\Forms\Form;
|
use SilverStripe\Forms\Form;
|
||||||
use SilverStripe\Forms\TextField;
|
use SilverStripe\Forms\TextField;
|
||||||
use SilverStripe\Control\Email\Email;
|
use SilverStripe\Control\Email\Email;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent class of all test pages
|
* Parent class of all test pages
|
||||||
@ -40,29 +38,31 @@ class TestPage extends Page
|
|||||||
$class = $this->class;
|
$class = $this->class;
|
||||||
if (!DataObject::get_one($class)) {
|
if (!DataObject::get_one($class)) {
|
||||||
// Try to create common parent
|
// Try to create common parent
|
||||||
$parent = SiteTree::get()
|
Member::actAs(Security::findAnAdministrator(), function () use ($class) {
|
||||||
->filter('URLSegment', 'feature-test-pages')
|
$parent = SiteTree::get()
|
||||||
->First();
|
->filter('URLSegment', 'feature-test-pages')
|
||||||
|
->First();
|
||||||
|
|
||||||
if (!$parent) {
|
if (!$parent) {
|
||||||
$parent = new Page(array(
|
$parent = new Page(array(
|
||||||
'Title' => 'Feature Test Pages',
|
'Title' => 'Feature Test Pages',
|
||||||
'Content' => 'A collection of pages for testing various features in the SilverStripe CMS',
|
'Content' => 'A collection of pages for testing various features in the SilverStripe CMS',
|
||||||
'ShowInMenus' => 0
|
'ShowInMenus' => 0
|
||||||
));
|
));
|
||||||
$parent->write();
|
$parent->write();
|
||||||
$parent->doPublish();
|
$parent->doPublish();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create actual page
|
// Create actual page
|
||||||
$page = new $class();
|
$page = new $class();
|
||||||
$page->Title = str_replace("SilverStripe\\FrameworkTest\\Model\\TestPage", "", $class);
|
$page->Title = str_replace("SilverStripe\\FrameworkTest\\Model\\TestPage", "", $class);
|
||||||
$page->ShowInMenus = 0;
|
$page->ShowInMenus = 0;
|
||||||
if ($parent) {
|
if ($parent) {
|
||||||
$page->ParentID = $parent->ID;
|
$page->ParentID = $parent->ID;
|
||||||
}
|
}
|
||||||
$page->write();
|
$page->write();
|
||||||
$page->publish('Stage', 'Live');
|
$page->publish('Stage', 'Live');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user