silverstripe-framework/tests/model/DataObjectSchemaTest_Namespaced.php
Damian Mooyman 5e8ae41d47 API Refactor dataobject schema management into separate service
API Allow table_name to be configured via Config
2016-06-08 13:22:56 +12:00

79 lines
1.8 KiB
PHP

<?php
/**
* Namespaced dataobjcets used by DataObjectSchemaTest
*/
namespace Namespaced\DOST;
/**
* Basic namespaced object
*/
class MyObject extends \DataObject implements \TestOnly {
private static $db = [
'Title' => 'Varchar',
'Description' => 'Text',
];
}
/**
* Namespaced object with custom table
*/
class MyObject_CustomTable extends \DataObject implements \TestOnly {
private static $table_name = 'CustomNamespacedTable';
private static $db = [
'Title' => 'Varchar',
'Description' => 'Text',
];
private static $belongs_many_many = [
'Parents' => 'Namespaced\DOST\MyObject_Namespaced_Subclass',
];
}
/**
* Namespaced subclassed object
*/
class MyObject_NestedObject extends MyObject implements \TestOnly {
private static $db = [
'Content' => 'HTMLText',
];
}
/**
* Namespaced object with custom table that itself is namespaced
*/
class MyObject_NamespacedTable extends \DataObject implements \TestOnly {
private static $table_name = 'Custom\NamespacedTable';
private static $db = [
'Title' => 'Varchar',
'Description' => 'Text',
];
private static $has_one = [
'Owner' => 'Namespaced\DOST\MyObject_NoFields',
];
}
/**
* Subclass of a namespaced class
* Has a many_many to another namespaced table
*/
class MyObject_Namespaced_Subclass extends MyObject_NamespacedTable implements \TestOnly {
private static $table_name = 'Custom\SubclassedTable';
private static $db = [
'Details' => 'Varchar',
];
private static $many_many = [
'Children' => 'Namespaced\DOST\MyObject_CustomTable',
];
}
/**
* Namespaced class without any fields
* has a has_many to another namespaced table
*/
class MyObject_NoFields extends \DataObject implements \TestOnly {
private static $has_many = [
'Owns' => 'Namespaced\DOST\MyObject_NamespacedTable',
];
}