mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-01 13:48:37 +02:00
FEATURE: Add dev/build/defaults to call requireDefaultRecords (from r104093)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112334 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ea32270eac
commit
d50097e905
@ -119,6 +119,18 @@ class DatabaseAdmin extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the default data, calling requireDefaultRecords on all
|
||||||
|
* DataObject classes
|
||||||
|
*/
|
||||||
|
function buildDefaults() {
|
||||||
|
$dataClasses = ClassInfo::subclassesFor('DataObject');
|
||||||
|
array_shift($dataClasses);
|
||||||
|
foreach($dataClasses as $dataClass){
|
||||||
|
singleton($dataClass)->requireDefaultRecords();
|
||||||
|
print "Defaults loaded for $dataClass<br/>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the timestamp of the time that the database was last built
|
* Returns the timestamp of the time that the database was last built
|
||||||
|
@ -12,6 +12,7 @@ class DevelopmentAdmin extends Controller {
|
|||||||
|
|
||||||
static $url_handlers = array(
|
static $url_handlers = array(
|
||||||
'' => 'index',
|
'' => 'index',
|
||||||
|
'build/defaults' => 'buildDefaults',
|
||||||
'$Action' => '$Action',
|
'$Action' => '$Action',
|
||||||
'$Action//$Action/$ID' => 'handleAction',
|
'$Action//$Action/$ID' => 'handleAction',
|
||||||
);
|
);
|
||||||
@ -135,6 +136,30 @@ class DevelopmentAdmin extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the default data, calling requireDefaultRecords on all
|
||||||
|
* DataObject classes
|
||||||
|
* Should match the $url_handlers rule:
|
||||||
|
* 'build/defaults' => 'buildDefaults',
|
||||||
|
*/
|
||||||
|
function buildDefaults() {
|
||||||
|
$da = new DatabaseAdmin();
|
||||||
|
|
||||||
|
if (!Director::is_cli()) {
|
||||||
|
$renderer = new DebugView();
|
||||||
|
$renderer->writeHeader();
|
||||||
|
$renderer->writeInfo("Defaults Builder", Director::absoluteBaseURL());
|
||||||
|
echo "<div style=\"margin: 0 2em\">";
|
||||||
|
}
|
||||||
|
|
||||||
|
$da->buildDefaults();
|
||||||
|
|
||||||
|
if (!Director::is_cli()) {
|
||||||
|
echo "</div>";
|
||||||
|
$renderer->writeFooter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
$link = BASE_URL.'/dev/tests/startsession';
|
$link = BASE_URL.'/dev/tests/startsession';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user