2019-01-18 01:56:58 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use SilverStripe\FrameworkTest\Model\TestPage;
|
|
|
|
use SilverStripe\ORM\DataObject;
|
|
|
|
use SilverStripe\Registry\RegistryPage;
|
|
|
|
use SilverStripe\Security\DefaultAdminService;
|
|
|
|
use SilverStripe\Security\Member;
|
|
|
|
|
2022-09-15 07:02:03 +02:00
|
|
|
if (!class_exists(RegistryPage::class)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-18 01:56:58 +01:00
|
|
|
class TestRegistryPage extends RegistryPage
|
|
|
|
{
|
|
|
|
public function requireDefaultRecords()
|
|
|
|
{
|
|
|
|
if (!DataObject::get_one(static::class)) {
|
|
|
|
// Try to create common parent
|
|
|
|
$defaultAdminService = DefaultAdminService::singleton();
|
|
|
|
Member::actAs($defaultAdminService->findOrCreateDefaultAdmin(), function () {
|
|
|
|
$page = new static;
|
|
|
|
$page->Title = 'Registry Test Page';
|
|
|
|
$page->ShowInMenus = 0;
|
|
|
|
$parent = TestPage::getOrCreateParentPage();
|
|
|
|
$page->ParentID = $parent->ID;
|
|
|
|
$page->DataClass = TestRegistryDataObject::class;
|
|
|
|
$page->write();
|
2022-08-30 03:18:41 +02:00
|
|
|
$page->copyVersionToStage('Stage', 'Live');
|
2019-01-18 01:56:58 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|