2016-05-25 07:09:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Namespaced dataobjcets used by DataObjectSchemaTest
|
|
|
|
*/
|
|
|
|
namespace Namespaced\DOST;
|
2016-06-15 06:03:16 +02:00
|
|
|
use SilverStripe\ORM\DataObject;
|
2016-08-19 00:51:35 +02:00
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
|
2016-06-15 06:03:16 +02:00
|
|
|
|
2016-05-25 07:09:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Basic namespaced object
|
|
|
|
*/
|
2016-08-19 00:51:35 +02:00
|
|
|
class MyObject extends DataObject implements TestOnly {
|
2016-05-25 07:09:29 +02:00
|
|
|
private static $db = [
|
|
|
|
'Title' => 'Varchar',
|
|
|
|
'Description' => 'Text',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Namespaced object with custom table
|
|
|
|
*/
|
2016-08-19 00:51:35 +02:00
|
|
|
class MyObject_CustomTable extends DataObject implements TestOnly {
|
2016-05-25 07:09:29 +02:00
|
|
|
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
|
|
|
|
*/
|
2016-08-19 00:51:35 +02:00
|
|
|
class MyObject_NestedObject extends MyObject implements TestOnly {
|
2016-05-25 07:09:29 +02:00
|
|
|
private static $db = [
|
|
|
|
'Content' => 'HTMLText',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Namespaced object with custom table that itself is namespaced
|
|
|
|
*/
|
2016-08-19 00:51:35 +02:00
|
|
|
class MyObject_NamespacedTable extends DataObject implements TestOnly {
|
2016-05-25 07:09:29 +02:00
|
|
|
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
|
|
|
|
*/
|
2016-08-19 00:51:35 +02:00
|
|
|
class MyObject_Namespaced_Subclass extends MyObject_NamespacedTable implements TestOnly {
|
2016-05-25 07:09:29 +02:00
|
|
|
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
|
|
|
|
*/
|
2016-08-19 00:51:35 +02:00
|
|
|
class MyObject_NoFields extends DataObject implements TestOnly {
|
2016-05-25 07:09:29 +02:00
|
|
|
private static $has_many = [
|
|
|
|
'Owns' => 'Namespaced\DOST\MyObject_NamespacedTable',
|
|
|
|
];
|
|
|
|
}
|