mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-02 22:28:37 +02:00
mlanthaler: Bugfix: Indexes and defaults were not supported in DataObjectDecorators?.
(merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41973 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9b75ec925a
commit
9af317a264
@ -10,7 +10,7 @@
|
|||||||
* DataObject decorators add extra functionality to your data objects.
|
* DataObject decorators add extra functionality to your data objects.
|
||||||
*/
|
*/
|
||||||
abstract class DataObjectDecorator extends Extension {
|
abstract class DataObjectDecorator extends Extension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the extra database fields defined in extraDBFields.
|
* Load the extra database fields defined in extraDBFields.
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,10 @@ abstract class DataObjectDecorator extends Extension {
|
|||||||
$className = $this->owner->class;
|
$className = $this->owner->class;
|
||||||
if($fields) {
|
if($fields) {
|
||||||
foreach($fields as $relationType => $fields) {
|
foreach($fields as $relationType => $fields) {
|
||||||
if(in_array($relationType, array('db','has_one','many_many','belongs_many_many','many_many_extraFields'))) {
|
if(in_array($relationType, array('db', 'has_one', 'indexes',
|
||||||
|
'defaults', 'many_many',
|
||||||
|
'belongs_many_many',
|
||||||
|
'many_many_extraFields'))) {
|
||||||
eval("$className::\$$relationType = array_merge((array){$className}::\$$relationType, (array)\$fields);");
|
eval("$className::\$$relationType = array_merge((array){$className}::\$$relationType, (array)\$fields);");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,14 +36,14 @@ abstract class DataObjectDecorator extends Extension {
|
|||||||
function augmentSQL(SQLQuery &$query) {
|
function augmentSQL(SQLQuery &$query) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the database schema as required by this extension.
|
* Update the database schema as required by this extension.
|
||||||
*/
|
*/
|
||||||
function augmentDatabase() {
|
function augmentDatabase() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define extra database fields.
|
* Define extra database fields.
|
||||||
* Return an map where the keys are db, has_one, etc, and the values are additional fields / relations to be defined.
|
* Return an map where the keys are db, has_one, etc, and the values are additional fields / relations to be defined.
|
||||||
@ -51,7 +54,7 @@ abstract class DataObjectDecorator extends Extension {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used to provide modifications to the form in the CMS by the
|
* This function is used to provide modifications to the form in the CMS by the
|
||||||
* decorator. By default, no changes are made - if you want you can overload
|
* decorator. By default, no changes are made - if you want you can overload
|
||||||
* this function.
|
* this function.
|
||||||
*/
|
*/
|
||||||
function updateCMSFields(FieldSet &$fields) {
|
function updateCMSFields(FieldSet &$fields) {
|
||||||
|
Loading…
Reference in New Issue
Block a user