mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-29 22:16:01 +02:00
svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2.2 ........ r50805 | ischommer | 2008-03-11 10:23:53 +1300 (Tue, 11 Mar 2008) | 2 lines added $searchable_fields in preparation for a more generic search implementation, currently limited to Member.php and MemberTableField.php (mainly to fix bugs caused by r49774 and r47856) fixed weird indentation formatting in Member.php ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@50802 467b73ca-7a2a-4603-9d3b-597d59a354a9
98 lines
2.1 KiB
PHP
Executable File
98 lines
2.1 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* @package sapphire
|
|
* @subpackage model
|
|
*/
|
|
|
|
|
|
/**
|
|
* Plug-ins for additional functionality in your DataObjects
|
|
*
|
|
* DataObject decorators add extra functionality to your data objects.
|
|
* @package sapphire
|
|
* @subpackage model
|
|
*/
|
|
abstract class DataObjectDecorator extends Extension {
|
|
|
|
/**
|
|
* Statics on a {@link DataObject} subclass
|
|
* which can be decorated onto. This list is
|
|
* limited for security and performance reasons.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected static $decoratable_statics = array(
|
|
'db',
|
|
'has_one',
|
|
'indexes',
|
|
'defaults',
|
|
'has_many',
|
|
'many_many',
|
|
'belongs_many_many',
|
|
'many_many_extraFields',
|
|
'searchable_fields',
|
|
);
|
|
|
|
/**
|
|
* Load the extra database fields defined in extraDBFields.
|
|
*
|
|
* @todo Rename to "extraStaticFields", as it decorates more than database related fields.
|
|
*/
|
|
function loadExtraDBFields() {
|
|
$fields = $this->extraDBFields();
|
|
$className = $this->owner->class;
|
|
|
|
if($fields) {
|
|
foreach($fields as $relationType => $fields) {
|
|
if(in_array($relationType, self::$decoratable_statics)) {
|
|
eval("$className::\$$relationType = array_merge((array){$className}::\$$relationType, (array)\$fields);");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Edit the given query object to support queries for this extension
|
|
*
|
|
* @param SQLQuery $query Query to augment.
|
|
*/
|
|
function augmentSQL(SQLQuery &$query) {
|
|
}
|
|
|
|
|
|
/**
|
|
* Update the database schema as required by this extension.
|
|
*/
|
|
function augmentDatabase() {
|
|
}
|
|
|
|
|
|
/**
|
|
* Define extra database fields
|
|
*
|
|
* Return a map where the keys are db, has_one, etc, and the values are
|
|
* additional fields/relations to be defined.
|
|
*
|
|
* @return array Returns a map where the keys are db, has_one, etc, and
|
|
* the values are additional fields/relations to be defined.
|
|
*/
|
|
function extraDBFields() {
|
|
return array();
|
|
}
|
|
|
|
|
|
/**
|
|
* 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 this
|
|
* function.
|
|
*
|
|
* @param FieldSet $fields The FieldSet to modify.
|
|
*/
|
|
function updateCMSFields(FieldSet &$fields) {
|
|
}
|
|
}
|
|
|
|
?>
|