mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Renamed DataObjectDecorator->loadExtraDBFields() to loadExtraStatics()
API CHANGE Renamed DataObjectDecorator->extraDBFields() to extraStatics() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65065 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
4f23d59636
commit
09564b0132
@ -216,7 +216,7 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP
|
||||
|
||||
// Define the extra db fields
|
||||
if($this->extension_instances) foreach($this->extension_instances as $i => $instance) {
|
||||
$instance->loadExtraDBFields();
|
||||
$instance->loadExtraStatics();
|
||||
}
|
||||
|
||||
// Set up accessors for joined items
|
||||
|
@ -28,15 +28,13 @@ abstract class DataObjectDecorator extends Extension implements i18nEntityProvid
|
||||
);
|
||||
|
||||
/**
|
||||
* Load the extra database fields defined in extraDBFields.
|
||||
*
|
||||
* @todo Rename to "loadExtraStaticFields", as it decorates more than database related fields.
|
||||
* Load the extra database fields defined in extraStatics.
|
||||
*/
|
||||
function loadExtraDBFields() {
|
||||
function loadExtraStatics() {
|
||||
// Don't apply DB fields if the parent object has this extension too
|
||||
if(singleton(get_parent_class($this->owner))->extInstance($this->class)) return;
|
||||
|
||||
$fields = $this->extraDBFields();
|
||||
$fields = $this->extraStatics();
|
||||
$className = $this->owner->class;
|
||||
|
||||
if($fields) {
|
||||
@ -51,6 +49,13 @@ abstract class DataObjectDecorator extends Extension implements i18nEntityProvid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.3 Use loadExtraStatics()
|
||||
*/
|
||||
function loadExtraDBFields() {
|
||||
return $this->loadExtraStatics();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -92,6 +97,13 @@ abstract class DataObjectDecorator extends Extension implements i18nEntityProvid
|
||||
* @return array Returns a map where the keys are db, has_one, etc, and
|
||||
* the values are additional fields/relations to be defined.
|
||||
*/
|
||||
function extraStatics() {
|
||||
return $this->extraDBFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.3 Use extraStatics()
|
||||
*/
|
||||
function extraDBFields() {
|
||||
return array();
|
||||
}
|
||||
@ -130,7 +142,7 @@ abstract class DataObjectDecorator extends Extension implements i18nEntityProvid
|
||||
* $extra_fields['summary_fields']
|
||||
*/
|
||||
function updateSummaryFields(&$fields){
|
||||
$extra_fields = $this->extraDBFields();
|
||||
$extra_fields = $this->extraStatics();
|
||||
if(isset($extra_fields['summary_fields'])){
|
||||
$summary_fields = $extra_fields['summary_fields'];
|
||||
if($summary_fields) $fields = array_merge($fields, $summary_fields);
|
||||
@ -144,7 +156,7 @@ abstract class DataObjectDecorator extends Extension implements i18nEntityProvid
|
||||
* $extra_fields['field_labels']
|
||||
*/
|
||||
function updateFieldLabels(&$lables){
|
||||
$extra_fields = $this->extraDBFields();
|
||||
$extra_fields = $this->extraStatics();
|
||||
if(isset($extra_fields['field_labels'])){
|
||||
$field_labels = $extra_fields['field_labels'];
|
||||
if($field_labels) $lables = array_merge($lables, $field_labels);
|
||||
@ -153,7 +165,7 @@ abstract class DataObjectDecorator extends Extension implements i18nEntityProvid
|
||||
|
||||
function provideI18nEntities() {
|
||||
$entities = array();
|
||||
$fields = $this->extraDBFields();
|
||||
$fields = $this->extraStatics();
|
||||
$translatableAttributes = array('db','has_one','has_many','many_many');
|
||||
if($fields) foreach($fields as $att => $spec) {
|
||||
if(!in_array($att, $translatableAttributes)) continue;
|
||||
|
@ -48,7 +48,7 @@ class Versioned extends DataObjectDecorator {
|
||||
$this->liveStage = array_pop($stages);
|
||||
}
|
||||
|
||||
function extraDbFields() {
|
||||
function extraStatics() {
|
||||
return array(
|
||||
'has_many' => array(
|
||||
'Versions' => 'SiteTree',
|
||||
|
@ -44,7 +44,7 @@ class DataObjectDecoratorTest_Member extends DataObject implements TestOnly {
|
||||
|
||||
class DataObjectDecoratorTest_ContactRole extends DataObjectDecorator implements TestOnly {
|
||||
|
||||
function extraDBFields() {
|
||||
function extraStatics() {
|
||||
return array(
|
||||
'db' => array(
|
||||
'Website' => 'Text',
|
||||
|
@ -576,7 +576,7 @@ class DataObjectTest_SubTeam extends DataObjectTest_Team implements TestOnly {
|
||||
|
||||
class DataObjectTest_Team_Decorator extends DataObjectDecorator implements TestOnly {
|
||||
|
||||
function extraDBFields() {
|
||||
function extraStatics() {
|
||||
return array(
|
||||
'db' => array(
|
||||
'DecoratedDatabaseField' => 'Text'
|
||||
|
Loading…
Reference in New Issue
Block a user