2011-04-15 11:35:30 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2012-09-26 23:34:00 +02:00
|
|
|
* An extension that adds additional functionality to a {@link DataObject}.
|
2011-04-15 11:35:30 +02:00
|
|
|
*
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2011-04-15 11:35:30 +02:00
|
|
|
* @subpackage model
|
|
|
|
*/
|
|
|
|
abstract class DataExtension extends Extension {
|
|
|
|
|
2011-09-23 10:03:28 +02:00
|
|
|
public static function unload_extra_statics($class, $extension) {
|
2011-12-22 03:29:16 +01:00
|
|
|
throw new Exception('unload_extra_statics gone');
|
2011-09-23 10:03:28 +02:00
|
|
|
}
|
2012-04-13 06:18:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook for extension-specific validation.
|
|
|
|
*
|
|
|
|
* @param $validationResult Local validation result
|
|
|
|
* @throws ValidationException
|
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function validate(ValidationResult $validationResult) {
|
2012-04-13 06:18:06 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2011-04-15 11:35:30 +02:00
|
|
|
/**
|
|
|
|
* Edit the given query object to support queries for this extension
|
|
|
|
*
|
2013-06-21 00:32:08 +02:00
|
|
|
* @param SQLSelect $query Query to augment.
|
2015-07-31 05:49:35 +02:00
|
|
|
* @param DataQuery $dataQuery Container DataQuery for this SQLSelect
|
2011-04-15 11:35:30 +02:00
|
|
|
*/
|
2015-06-09 01:31:07 +02:00
|
|
|
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null) {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the database schema as required by this extension.
|
2011-09-19 04:20:38 +02:00
|
|
|
*
|
|
|
|
* When duplicating a table's structure, remember to duplicate the create options
|
|
|
|
* as well. See {@link Versioned->augmentDatabase} for an example.
|
2011-04-15 11:35:30 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function augmentDatabase() {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2011-04-15 11:35:30 +02:00
|
|
|
/**
|
|
|
|
* Augment a write-record request.
|
|
|
|
*
|
2013-06-21 00:32:08 +02:00
|
|
|
* @param array $manipulation Array of operations to augment.
|
2011-04-15 11:35:30 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function augmentWrite(&$manipulation) {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function onBeforeWrite() {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function onAfterWrite() {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function onBeforeDelete() {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function onAfterDelete() {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function requireDefaultRecords() {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function populateDefaults() {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function can($member) {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function canEdit($member) {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function canDelete($member) {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function canCreate($member) {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2011-10-30 23:17:37 +01:00
|
|
|
* @param $class since this method might be called on the class directly
|
|
|
|
* @param $extension since this can help to extract parameters to help set indexes
|
2011-04-15 11:35:30 +02:00
|
|
|
*
|
|
|
|
* @return array Returns a map where the keys are db, has_one, etc, and
|
|
|
|
* the values are additional fields/relations to be defined.
|
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function extraStatics($class = null, $extension = null) {
|
2011-04-15 11:35:30 +02:00
|
|
|
return array();
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2011-04-15 11:35:30 +02:00
|
|
|
/**
|
|
|
|
* This function is used to provide modifications to the form in the CMS
|
|
|
|
* by the extension. By default, no changes are made. {@link DataObject->getCMSFields()}.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2011-04-15 11:35:30 +02:00
|
|
|
* Please consider using {@link updateFormFields()} to globally add
|
|
|
|
* formfields to the record. The method {@link updateCMSFields()}
|
|
|
|
* should just be used to add or modify tabs, or fields which
|
|
|
|
* are specific to the CMS-context.
|
|
|
|
*
|
2011-05-11 09:51:54 +02:00
|
|
|
* Caution: Use {@link FieldList->addFieldToTab()} to add fields.
|
2011-04-15 11:35:30 +02:00
|
|
|
*
|
2011-10-28 03:37:27 +02:00
|
|
|
* @param FieldList $fields FieldList with a contained TabSet
|
2011-04-15 11:35:30 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function updateCMSFields(FieldList $fields) {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2011-04-15 11:35:30 +02:00
|
|
|
/**
|
|
|
|
* This function is used to provide modifications to the form used
|
|
|
|
* for front end forms. {@link DataObject->getFrontEndFields()}
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2011-10-28 03:37:27 +02:00
|
|
|
* Caution: Use {@link FieldList->push()} to add fields.
|
2011-04-15 11:35:30 +02:00
|
|
|
*
|
2011-10-28 03:37:27 +02:00
|
|
|
* @param FieldList $fields FieldList without TabSet nesting
|
2011-04-15 11:35:30 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function updateFrontEndFields(FieldList $fields) {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2011-04-15 11:35:30 +02:00
|
|
|
/**
|
|
|
|
* This is used to provide modifications to the form actions
|
|
|
|
* used in the CMS. {@link DataObject->getCMSActions()}.
|
|
|
|
*
|
2011-10-28 03:37:27 +02:00
|
|
|
* @param FieldList $actions FieldList
|
2011-04-15 11:35:30 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function updateCMSActions(FieldList $actions) {
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2011-04-15 11:35:30 +02:00
|
|
|
/**
|
|
|
|
* this function is used to provide modifications to the summary fields in CMS
|
|
|
|
* by the extension
|
|
|
|
* By default, the summaryField() of its owner will merge more fields defined in the extension's
|
|
|
|
* $extra_fields['summary_fields']
|
2012-04-18 22:30:12 +02:00
|
|
|
*
|
|
|
|
* @param array $fields Array of field names
|
2011-04-15 11:35:30 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function updateSummaryFields(&$fields) {
|
2012-04-18 22:30:12 +02:00
|
|
|
$summary_fields = Config::inst()->get($this->class, 'summary_fields');
|
|
|
|
if($summary_fields) {
|
2011-04-15 11:35:30 +02:00
|
|
|
// if summary_fields were passed in numeric array,
|
|
|
|
// convert to an associative array
|
|
|
|
if($summary_fields && array_key_exists(0, $summary_fields)) {
|
|
|
|
$summary_fields = array_combine(array_values($summary_fields), array_values($summary_fields));
|
|
|
|
}
|
|
|
|
if($summary_fields) $fields = array_merge($fields, $summary_fields);
|
|
|
|
}
|
|
|
|
}
|
2012-04-18 22:30:12 +02:00
|
|
|
|
2011-04-15 11:35:30 +02:00
|
|
|
/**
|
|
|
|
* this function is used to provide modifications to the fields labels in CMS
|
|
|
|
* by the extension
|
|
|
|
* By default, the fieldLabels() of its owner will merge more fields defined in the extension's
|
|
|
|
* $extra_fields['field_labels']
|
2012-04-18 22:30:12 +02:00
|
|
|
*
|
|
|
|
* @param array $labels Array of field labels
|
2011-04-15 11:35:30 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function updateFieldLabels(&$labels) {
|
2012-04-18 22:30:12 +02:00
|
|
|
$field_labels = Config::inst()->get($this->class, 'field_labels');
|
|
|
|
if($field_labels) {
|
|
|
|
$labels = array_merge($labels, $field_labels);
|
2011-04-15 11:35:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|