Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Default data structures on build


3 Posts   1219 Views


18 February 2009 at 4:41pm Community Member, 712 Posts

Hi all,

Is it possible to provide a set of sample data (ie, as yml) that will automatically be loaded on dev/build? The test runner does this, just wondering if it is possible for normal projects.

This would be great for populating certain objects when the database is built.


18 February 2009 at 5:54pm Community Member, 244 Posts

requireDefaultRecords() is run on each DataObject when the DataObject is built - so you could just do something like:

public function requireDefaultRecords() {
   if(!DataObject::get_one('PageType')) {
      $pageType = new PageType();
      // ...


18 February 2009 at 9:25pm Community Member, 712 Posts

Cheers AJ, that's the sort of thing I'm looking for.