silverstripe-frameworktest/code/TestCategory.php
Ingo Schommer e15366359e 3.1 compat
2013-03-26 13:53:37 +01:00

36 lines
783 B
PHP

<?php
/**
* A data type that is related many-many to RelationFieldsTestPage, for testing purposes
*/
class TestCategory extends DataObject {
private static $db = array(
"Title" => "Varchar",
);
private static $belongs_many_many = array(
"RelationPages" => "RelationFieldsTestPage",
);
/**
* Returns a dropdown map of all objects of this class
*/
static function map() {
$categories = DataObject::get('TestCategory');
if($categories) return $categories->map('ID', 'Title')->toArray();
else return array();
}
function requireDefaultRecords(){
$class = $this->class;
if(!DataObject::get_one($class)) {
foreach(array("A","B","C","D") as $item) {
$page = new $class();
$page->Title = "Test Category $item";
$page->write();
}
}
}
}
?>