mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #11348 from creative-commoners/pulls/6/replace-extension-subclasses
API Replace Extension subclasses
This commit is contained in:
commit
3d79660662
@ -10,7 +10,6 @@ use SilverStripe\Config\Middleware\MiddlewareCommon;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
class ExtensionMiddleware implements Middleware
|
||||
{
|
||||
@ -83,8 +82,6 @@ class ExtensionMiddleware implements Middleware
|
||||
// Skip base classes
|
||||
switch ($extensionClassParent) {
|
||||
case Extension::class:
|
||||
case DataExtension::class:
|
||||
continue 2;
|
||||
default:
|
||||
// continue
|
||||
}
|
||||
|
@ -154,7 +154,6 @@ trait Extensible
|
||||
* Keep in mind that the extension will only be applied to new
|
||||
* instances, not existing ones (including all instances created through {@link singleton()}).
|
||||
*
|
||||
* @see http://doc.silverstripe.org/framework/en/trunk/reference/dataextension
|
||||
* @param string $classOrExtension Class that should be extended - has to be a subclass of {@link Object}
|
||||
* @param string $extension Subclass of {@link Extension} with optional parameters
|
||||
* as a string, e.g. "Versioned"
|
||||
@ -256,7 +255,7 @@ trait Extensible
|
||||
* @param string $class If omitted, will get extensions for the current class
|
||||
* @param bool $includeArgumentString Include the argument string in the return array,
|
||||
* FALSE would return array("Versioned"), TRUE returns array("Versioned('Stage','Live')").
|
||||
* @return array Numeric array of either {@link DataExtension} class names,
|
||||
* @return array Numeric array of either {@link Extension} class names,
|
||||
* or eval'ed class name strings with constructor arguments.
|
||||
*/
|
||||
public static function get_extensions($class = null, $includeArgumentString = false)
|
||||
@ -501,7 +500,7 @@ trait Extensible
|
||||
*
|
||||
* This method also provides lazy-population of the extension_instances property.
|
||||
*
|
||||
* @return Extension[] Map of {@link DataExtension} instances, keyed by classname.
|
||||
* @return Extension[] Map of {@link Extension} instances, keyed by classname.
|
||||
*/
|
||||
public function getExtensionInstances()
|
||||
{
|
||||
|
@ -7,7 +7,6 @@ use SilverStripe\ORM\DataObject;
|
||||
|
||||
/**
|
||||
* Add extension that can be added to an object with {@link Object::add_extension()}.
|
||||
* For {@link DataObject} extensions, use {@link DataExtension}.
|
||||
* Each extension instance has an "owner" instance, accessible through
|
||||
* {@link getOwner()}.
|
||||
* Every object instance gets its own set of extension instances,
|
||||
|
@ -24,7 +24,7 @@ use SilverStripe\ORM\ValidationResult;
|
||||
* return $compositeValidator
|
||||
* }
|
||||
*
|
||||
* Or by implementing the updateCMSCompositeValidator() method in a DataExtension:
|
||||
* Or by implementing the updateCMSCompositeValidator() method in an Extension:
|
||||
*
|
||||
* protected function updateCMSCompositeValidator(CompositeValidator $compositeValidator): void
|
||||
* {
|
||||
|
@ -6,10 +6,10 @@ use Exception;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Environment;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
|
||||
@ -148,9 +148,9 @@ class TempDatabase
|
||||
return;
|
||||
}
|
||||
|
||||
// Some DataExtensions keep a static cache of information that needs to
|
||||
// Some Extensions keep a static cache of information that needs to
|
||||
// be reset whenever the database is killed
|
||||
foreach (ClassInfo::subclassesFor(DataExtension::class) as $class) {
|
||||
foreach (ClassInfo::subclassesFor(Extension::class) as $class) {
|
||||
$toCall = [$class, 'on_db_reset'];
|
||||
if (is_callable($toCall)) {
|
||||
call_user_func($toCall);
|
||||
@ -171,10 +171,10 @@ class TempDatabase
|
||||
|
||||
$this->getConn()->clearAllData();
|
||||
|
||||
// Some DataExtensions keep a static cache of information that needs to
|
||||
// Some Extensions keep a static cache of information that needs to
|
||||
// be reset whenever the database is cleaned out
|
||||
$classes = array_merge(
|
||||
ClassInfo::subclassesFor(DataExtension::class),
|
||||
ClassInfo::subclassesFor(Extension::class),
|
||||
ClassInfo::subclassesFor(DataObject::class)
|
||||
);
|
||||
foreach ($classes as $class) {
|
||||
|
@ -1,297 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\CompositeValidator;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\Security\Member;
|
||||
use Exception;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
/**
|
||||
* An extension that adds additional functionality to a {@link DataObject}.
|
||||
*
|
||||
* @template T of DataObject
|
||||
* @extends Extension<T>
|
||||
* @deprecated 5.3.0 Subclass SilverStripe\Core\Extension\Extension instead
|
||||
*/
|
||||
abstract class DataExtension extends Extension
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// Wrapping with Deprecation::withNoReplacement() to avoid triggering deprecation notices
|
||||
// as we are unable to update existing subclasses of this class until a new major
|
||||
// unless we add in the pointless empty methods that are in this class
|
||||
Deprecation::withNoReplacement(function () {
|
||||
$class = Extension::class;
|
||||
Deprecation::notice('5.3.0', "Subclass $class instead", Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for extension-specific validation.
|
||||
*
|
||||
* @param ValidationResult $validationResult Local validation result
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function updateValidate(ValidationResult $validationResult)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the given query object to support queries for this extension
|
||||
*
|
||||
* @param SQLSelect $query Query to augment.
|
||||
* @param DataQuery $dataQuery Container DataQuery for this SQLSelect
|
||||
*/
|
||||
protected function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the database schema as required by this extension.
|
||||
*
|
||||
* When duplicating a table's structure, remember to duplicate the create options
|
||||
* as well. See {@link Versioned->augmentDatabase} for an example.
|
||||
*/
|
||||
protected function augmentDatabase()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Augment a write-record request.
|
||||
*
|
||||
* @param array $manipulation Array of operations to augment.
|
||||
*/
|
||||
protected function augmentWrite(&$manipulation)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend the owner's onBeforeWrite() logic
|
||||
*
|
||||
* See {@link DataObject::onBeforeWrite()} for context.
|
||||
*/
|
||||
protected function onBeforeWrite()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend the owner's onAfterWrite() logic
|
||||
*
|
||||
* See {@link DataObject::onAfterWrite()} for context.
|
||||
*/
|
||||
protected function onAfterWrite()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend the owner's onBeforeDelete() logic
|
||||
*
|
||||
* See {@link DataObject::onBeforeDelete()} for context.
|
||||
*/
|
||||
protected function onBeforeDelete()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend the owner's onAfterDelete() logic
|
||||
*
|
||||
* See {@link DataObject::onAfterDelete()} for context.
|
||||
*/
|
||||
protected function onAfterDelete()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend the owner's requireDefaultRecords() logic
|
||||
*
|
||||
* See {@link DataObject::requireDefaultRecords()} for context.
|
||||
*/
|
||||
protected function onRequireDefaultRecords()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend the owner's populateDefaults() logic
|
||||
*
|
||||
* See {@link DataObject::populateDefaults()} for context.
|
||||
*/
|
||||
protected function onAfterPopulateDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend the owner's onAfterBuild() logic
|
||||
*
|
||||
* See {@link DataObject::onAfterBuild()} for context.
|
||||
*/
|
||||
protected function onAfterBuild()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Influence the owner's can() permission check value to be disallowed (false),
|
||||
* allowed (true) if no other processed results are to disallow, or open (null) to not
|
||||
* affect the outcome.
|
||||
*
|
||||
* See {@link DataObject::can()} and {@link DataObject::extendedCan()} for context.
|
||||
*
|
||||
* @param Member $member
|
||||
* @return bool|null
|
||||
*/
|
||||
protected function can($member)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Influence the owner's canEdit() permission check value to be disallowed (false),
|
||||
* allowed (true) if no other processed results are to disallow, or open (null) to not
|
||||
* affect the outcome.
|
||||
*
|
||||
* See {@link DataObject::canEdit()} and {@link DataObject::extendedCan()} for context.
|
||||
*
|
||||
* @param Member $member
|
||||
* @return bool|null
|
||||
*/
|
||||
protected function canEdit($member)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Influence the owner's canDelete() permission check value to be disallowed (false),
|
||||
* allowed (true) if no other processed results are to disallow, or open (null) to not
|
||||
* affect the outcome.
|
||||
*
|
||||
* See {@link DataObject::canDelete()} and {@link DataObject::extendedCan()} for context.
|
||||
*
|
||||
* @param Member $member
|
||||
* @return bool|null
|
||||
*/
|
||||
protected function canDelete($member)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Influence the owner's canCreate() permission check value to be disallowed (false),
|
||||
* allowed (true) if no other processed results are to disallow, or open (null) to not
|
||||
* affect the outcome.
|
||||
*
|
||||
* See {@link DataObject::canCreate()} and {@link DataObject::extendedCan()} for context.
|
||||
*
|
||||
* @param Member $member
|
||||
* @return bool|null
|
||||
*/
|
||||
protected function canCreate($member)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string $class since this method might be called on the class directly
|
||||
* @param string $extension since this can help to extract parameters to help set indexes
|
||||
* @return array Returns a map where the keys are db, has_one, etc, and
|
||||
* the values are additional fields/relations to be defined.
|
||||
*/
|
||||
public function extraStatics($class = null, $extension = null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()}.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Caution: Use {@link FieldList->addFieldToTab()} to add fields.
|
||||
*
|
||||
* @param FieldList $fields FieldList with a contained TabSet
|
||||
*/
|
||||
protected function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to provide modifications to the Validators used on a DataObject.
|
||||
*
|
||||
* Caution: Use {@link CompositeValidator->addValidator()} to add Validators.
|
||||
*
|
||||
* @param CompositeValidator $compositeValidator
|
||||
*/
|
||||
protected function updateCMSCompositeValidator(CompositeValidator $compositeValidator): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to provide modifications to the form used
|
||||
* for front end forms. {@link DataObject->getFrontEndFields()}
|
||||
*
|
||||
* Caution: Use {@link FieldList->push()} to add fields.
|
||||
*
|
||||
* @param FieldList $fields FieldList without TabSet nesting
|
||||
*/
|
||||
protected function updateFrontEndFields(FieldList $fields)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used to provide modifications to the form actions
|
||||
* used in the CMS. {@link DataObject->getCMSActions()}.
|
||||
*
|
||||
* @param FieldList $actions FieldList
|
||||
*/
|
||||
protected function updateCMSActions(FieldList $actions)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']
|
||||
*
|
||||
* @param array $fields Array of field names
|
||||
*/
|
||||
protected function updateSummaryFields(&$fields)
|
||||
{
|
||||
$summary_fields = Config::inst()->get(static::class, 'summary_fields');
|
||||
if ($summary_fields) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']
|
||||
*
|
||||
* @param array $labels Array of field labels
|
||||
*/
|
||||
protected function updateFieldLabels(&$labels)
|
||||
{
|
||||
$field_labels = Config::inst()->get(static::class, 'field_labels');
|
||||
if ($field_labels) {
|
||||
$labels = array_merge($labels, $field_labels);
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ use stdClass;
|
||||
*
|
||||
* <h2>Extensions</h2>
|
||||
*
|
||||
* See {@link Extension} and {@link DataExtension}.
|
||||
* See {@link Extension}
|
||||
*
|
||||
* <h2>Permission Control</h2>
|
||||
*
|
||||
@ -1212,7 +1212,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* Validate the current object.
|
||||
*
|
||||
* By default, there is no validation - objects are always valid! However, you can overload this method in your
|
||||
* DataObject sub-classes to specify custom validation, or use the hook through DataExtension.
|
||||
* DataObject sub-classes to specify custom validation, or use the hook through Extension.
|
||||
*
|
||||
* Invalid objects won't be able to be written - a warning will be thrown and no write will occur. onBeforeWrite()
|
||||
* and onAfterWrite() won't get called either.
|
||||
@ -1236,8 +1236,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* database. Don't forget to call parent::onBeforeWrite(), though!
|
||||
*
|
||||
* This called after {@link $this->validate()}, so you can be sure that your data is valid.
|
||||
*
|
||||
* @uses DataExtension::onBeforeWrite()
|
||||
*/
|
||||
protected function onBeforeWrite()
|
||||
{
|
||||
@ -1252,8 +1250,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* You can overload this to act upon changes made to the data after it is written.
|
||||
* $this->changed will have a record
|
||||
* database. Don't forget to call parent::onAfterWrite(), though!
|
||||
*
|
||||
* @uses DataExtension::onAfterWrite()
|
||||
*/
|
||||
protected function onAfterWrite()
|
||||
{
|
||||
@ -1282,8 +1278,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* Event handler called before deleting from the database.
|
||||
* You can overload this to clean up or otherwise process data before delete this
|
||||
* record. Don't forget to call parent::onBeforeDelete(), though!
|
||||
*
|
||||
* @uses DataExtension::onBeforeDelete()
|
||||
*/
|
||||
protected function onBeforeDelete()
|
||||
{
|
||||
@ -1563,8 +1557,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* - $this->onBeforeWrite() gets called beforehand.
|
||||
* - Extensions such as Versioned will amend the database-write to ensure that a version is saved.
|
||||
*
|
||||
* @uses DataExtension::augmentWrite()
|
||||
*
|
||||
* @param boolean $showDebug Show debugging information
|
||||
* @param boolean $forceInsert Run INSERT command rather than UPDATE, even if record already exists
|
||||
* @param boolean $forceWrite Write to database even if there are no changes
|
||||
@ -1737,7 +1729,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* Delete this data object.
|
||||
* $this->onBeforeDelete() gets called.
|
||||
* Note that in Versioned objects, both Stage and Live will be deleted.
|
||||
* @uses DataExtension::augmentSQL()
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
@ -2596,7 +2587,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* which returns a {@link FieldList} suitable for a {@link Form} object.
|
||||
* If not overloaded, we're using {@link scaffoldFormFields()} to automatically
|
||||
* generate this set. To customize, overload this method in a subclass
|
||||
* or extended onto it by using {@link DataExtension->updateCMSFields()}.
|
||||
* or use an Extension which implements updateCMSFields()
|
||||
*
|
||||
* <code>
|
||||
* class MyCustomClass extends DataObject {
|
||||
@ -2671,7 +2662,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* Used for simple frontend forms without relation editing
|
||||
* or {@link TabSet} behaviour. Uses {@link scaffoldFormFields()}
|
||||
* by default. To customize, either overload this method in your
|
||||
* subclass, or extend it by {@link DataExtension->updateFrontEndFields()}.
|
||||
* subclass, or create an Extensiona and implement updateFrontEndFields()
|
||||
*
|
||||
* @param array $params See {@link scaffoldFormFields()}
|
||||
* @return FieldList Always returns a simple field collection without TabSet.
|
||||
@ -3685,8 +3676,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
|
||||
/**
|
||||
* Check the database schema and update it as necessary.
|
||||
*
|
||||
* @uses DataExtension::augmentDatabase()
|
||||
*/
|
||||
public function requireTable()
|
||||
{
|
||||
@ -3767,8 +3756,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* database is built, after the database tables have all been created. Overload
|
||||
* this to add default records when the database is built, but make sure you
|
||||
* call parent::requireDefaultRecords().
|
||||
*
|
||||
* @uses DataExtension::requireDefaultRecords()
|
||||
*/
|
||||
public function requireDefaultRecords()
|
||||
{
|
||||
@ -3917,7 +3904,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
|
||||
$fields = $rewrite;
|
||||
|
||||
// apply DataExtensions if present
|
||||
$this->extend('updateSearchableFields', $fields);
|
||||
|
||||
return $fields;
|
||||
@ -4028,6 +4014,17 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
$rawFields = $this->config()->get('summary_fields');
|
||||
|
||||
// Merge associative / numeric keys
|
||||
// Key could be a mixture of key types for example
|
||||
// base class $summary_fields = ['Title'] - key is 0
|
||||
// extension class $summary-fields = ['Title' => 'Custom Title'] - key is 'Title'
|
||||
// Sort by numeric keys first so that any associative keys will override them later
|
||||
uksort($rawFields, function ($a, $b) {
|
||||
if (is_int($a) && !is_int($b)) {
|
||||
return -1;
|
||||
} elseif (!is_int($a) && is_int($b)) {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
$fields = [];
|
||||
foreach ($rawFields as $key => $value) {
|
||||
if (is_int($key)) {
|
||||
@ -4035,7 +4032,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
}
|
||||
$fields[$key] = $value;
|
||||
}
|
||||
|
||||
if (!$fields) {
|
||||
$fields = [];
|
||||
// try to scaffold a couple of usual suspects
|
||||
@ -4558,8 +4554,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
|
||||
/**
|
||||
* Extension point to add more cache key components.
|
||||
* The framework extend method will return combined values from DataExtension method(s) as an array
|
||||
* The method on your DataExtension class should return a single scalar value. For example:
|
||||
* The framework extend method will return combined values from Extension method(s) as an array
|
||||
* The method on your Extension class should return a single scalar value. For example:
|
||||
*
|
||||
* protected function cacheKeyComponent()
|
||||
* {
|
||||
|
@ -10,7 +10,7 @@ use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
@ -24,9 +24,9 @@ use SilverStripe\View\ViewableData;
|
||||
*
|
||||
* @property int $ParentID
|
||||
* @method DataObject Parent()
|
||||
* @extends DataExtension<DataObject&static>
|
||||
* @extends Extension<DataObject&static>
|
||||
*/
|
||||
class Hierarchy extends DataExtension
|
||||
class Hierarchy extends Extension
|
||||
{
|
||||
/**
|
||||
* The lower bounds for the amount of nodes to mark. If set, the logic will expand nodes until it reaches at least
|
||||
|
@ -7,7 +7,7 @@ use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
use SilverStripe\ORM\Connect\MySQLSchemaManager;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
@ -21,9 +21,9 @@ use Exception;
|
||||
* unless "File" is excluded from FulltextSearchable::enable().
|
||||
*
|
||||
* @template T of SiteTree|File
|
||||
* @extends DataExtension<T>
|
||||
* @extends Extension<T>
|
||||
*/
|
||||
class FulltextSearchable extends DataExtension
|
||||
class FulltextSearchable extends Extension
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -4,14 +4,14 @@ namespace SilverStripe\Security;
|
||||
|
||||
use Psr\Log\InvalidArgumentException;
|
||||
use SilverStripe\Core\Flushable;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Core\Cache\MemberCacheFlusher;
|
||||
|
||||
/**
|
||||
* @extends DataExtension<Member|Group>
|
||||
* @extends Extension<Member|Group>
|
||||
*/
|
||||
class InheritedPermissionFlusher extends DataExtension implements Flushable
|
||||
class InheritedPermissionFlusher extends Extension implements Flushable
|
||||
{
|
||||
/**
|
||||
* @var MemberCacheFlusher[]
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\ManyManyList;
|
||||
|
||||
/**
|
||||
@ -15,9 +15,9 @@ use SilverStripe\ORM\ManyManyList;
|
||||
* @method ManyManyList<Group> ViewerGroups()
|
||||
* @method ManyManyList<Member> ViewerMembers()
|
||||
*
|
||||
* @extends DataExtension<DataObject>
|
||||
* @extends Extension<DataObject>
|
||||
*/
|
||||
class InheritedPermissionsExtension extends DataExtension
|
||||
class InheritedPermissionsExtension extends Extension
|
||||
{
|
||||
private static array $db = [
|
||||
'CanViewType' => "Enum('Anyone, LoggedInUsers, OnlyTheseUsers, OnlyTheseMembers, Inherit', 'Inherit')",
|
||||
|
@ -686,7 +686,7 @@ class Member extends DataObject
|
||||
* Validator is used when saving a {@link CMSProfileController} or added to
|
||||
* any form responsible for saving a users data.
|
||||
*
|
||||
* To customize the required fields, add a {@link DataExtension} to member
|
||||
* To customize the required fields, add a {@link Extension} to member
|
||||
* calling the `updateValidator()` method.
|
||||
*
|
||||
* @return Member_Validator
|
||||
|
@ -9,7 +9,7 @@ use SilverStripe\Forms\RequiredFields;
|
||||
* Member Validator
|
||||
*
|
||||
* Custom validation for the Member object can be achieved either through an
|
||||
* {@link DataExtension} on the Member_Validator object or, by specifying a subclass of
|
||||
* {@link Extension} on the Member_Validator object or, by specifying a subclass of
|
||||
* {@link Member_Validator} through the {@link Injector} API.
|
||||
* The Validator can also be modified by adding an Extension to Member and implement the
|
||||
* <code>updateValidator</code> hook.
|
||||
|
@ -1098,7 +1098,7 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
return false;
|
||||
}
|
||||
|
||||
// HACK: DataExtensions aren't applied until a class is instantiated for
|
||||
// HACK: Extensions aren't applied until a class is instantiated for
|
||||
// the first time, so create an instance here.
|
||||
singleton($class);
|
||||
|
||||
|
@ -5,9 +5,9 @@ namespace SilverStripe\Forms\Tests\FormScaffolderTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class ArticleExtension extends DataExtension implements TestOnly
|
||||
class ArticleExtension extends Extension implements TestOnly
|
||||
{
|
||||
private static $db = [
|
||||
'ExtendedField' => 'Varchar'
|
||||
|
@ -3,11 +3,11 @@
|
||||
namespace SilverStripe\Forms\Tests\GridField\GridFieldTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\Filters\FulltextFilter;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\StadiumExtension;
|
||||
|
||||
class StadiumExtension extends DataExtension implements TestOnly
|
||||
class StadiumExtension extends Extension implements TestOnly
|
||||
{
|
||||
protected function updateSearchableFields(&$fields)
|
||||
{
|
||||
|
@ -4,9 +4,9 @@ namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
||||
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class AllMethodNames extends DataExtension implements TestOnly
|
||||
class AllMethodNames extends Extension implements TestOnly
|
||||
{
|
||||
public function allMethodNames()
|
||||
{
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class AppliedToDO extends DataExtension implements TestOnly
|
||||
class AppliedToDO extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
public function testMethodApplied()
|
||||
|
@ -5,12 +5,12 @@ namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
/**
|
||||
* Extension to top level test class, tests that updateCMSFields work
|
||||
*/
|
||||
class CMSFieldsBaseExtension extends DataExtension implements TestOnly
|
||||
class CMSFieldsBaseExtension extends Extension implements TestOnly
|
||||
{
|
||||
private static $db = [
|
||||
'ExtendedFieldKeep' => 'Varchar(255)',
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class ContactRole extends DataExtension implements TestOnly
|
||||
class ContactRole extends Extension implements TestOnly
|
||||
{
|
||||
private static $db = [
|
||||
'Website' => 'Varchar',
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class Extension1 extends DataExtension implements TestOnly
|
||||
class Extension1 extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
protected function canOne($member = null)
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class Extension2 extends DataExtension implements TestOnly
|
||||
class Extension2 extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
protected function canOne($member = null)
|
||||
|
@ -3,12 +3,11 @@
|
||||
namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\Tests\DataExtensionTest\RelatedObject;
|
||||
|
||||
class Faves extends DataExtension implements TestOnly
|
||||
class Faves extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
private static $many_many = [
|
||||
'Faves' => RelatedObject::class
|
||||
];
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\ORM\Tests\DataExtensionTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class PlayerExtension extends DataExtension implements TestOnly
|
||||
class PlayerExtension extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
public static function get_extra_config($class = null, $extensionClass = null, $args = null)
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\ORM\Tests\DataObjectTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class Team_Extension extends DataExtension implements TestOnly
|
||||
class Team_Extension extends Extension implements TestOnly
|
||||
{
|
||||
private static $summary_fields = [
|
||||
'Title' => 'Custom Title', // override non-associative 'Title'
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\ORM\Tests\ManyManyListTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\ManyManyList;
|
||||
|
||||
/**
|
||||
@ -12,7 +12,7 @@ use SilverStripe\ORM\ManyManyList;
|
||||
*
|
||||
* @method ManyManyList Primary()
|
||||
*/
|
||||
class IndirectSecondaryExtension extends DataExtension implements TestOnly
|
||||
class IndirectSecondaryExtension extends Extension implements TestOnly
|
||||
{
|
||||
private static $db = [
|
||||
'Title' => 'Varchar(255)'
|
||||
|
@ -106,7 +106,7 @@ class RelatedDataServiceTest extends SapphireTest
|
||||
|
||||
public function testUsageHasOneHubExtension()
|
||||
{
|
||||
// Add DataExtension and reset database so that tables + columns get added
|
||||
// Add Extension and reset database so that tables + columns get added
|
||||
Hub::add_extension(HubExtension::class);
|
||||
DataObject::reset();
|
||||
RelatedDataServiceTest::resetDBSchema(true, true);
|
||||
@ -212,7 +212,7 @@ class RelatedDataServiceTest extends SapphireTest
|
||||
|
||||
public function testUsageManyManyWithoutBelongsHubExtension()
|
||||
{
|
||||
// Add DataExtension and reset database so that tables + columns get added
|
||||
// Add Extension and reset database so that tables + columns get added
|
||||
Hub::add_extension(HubExtension::class);
|
||||
DataObject::reset();
|
||||
RelatedDataServiceTest::resetDBSchema(true, true);
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\ORM\Tests\RelatedDataServiceTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class HubExtension extends DataExtension implements TestOnly
|
||||
class HubExtension extends Extension implements TestOnly
|
||||
{
|
||||
private static $has_one = [
|
||||
'ExtHO' => Node::class
|
||||
|
@ -3,12 +3,12 @@
|
||||
namespace SilverStripe\Security\Tests\MemberTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
/**
|
||||
* Extension that adds additional validation criteria
|
||||
*/
|
||||
class AlwaysFailExtension extends DataExtension implements TestOnly
|
||||
class AlwaysFailExtension extends Extension implements TestOnly
|
||||
{
|
||||
protected function updatePHP($data, $form)
|
||||
{
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Security\Tests\MemberTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class EditingAllowedDeletingDeniedExtension extends DataExtension implements TestOnly
|
||||
class EditingAllowedDeletingDeniedExtension extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
protected function canView($member = null)
|
||||
|
@ -3,13 +3,13 @@
|
||||
namespace SilverStripe\Security\Tests\MemberTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
|
||||
/**
|
||||
* Extension that does something extra when changing a member's password
|
||||
*/
|
||||
class ExtendedChangePasswordExtension extends DataExtension implements TestOnly
|
||||
class ExtendedChangePasswordExtension extends Extension implements TestOnly
|
||||
{
|
||||
protected function onBeforeChangePassword($newPassword, $valid)
|
||||
{
|
||||
|
@ -5,9 +5,9 @@ namespace SilverStripe\Security\Tests\MemberTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class FieldsExtension extends DataExtension implements TestOnly
|
||||
class FieldsExtension extends Extension implements TestOnly
|
||||
{
|
||||
protected function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
|
@ -3,12 +3,12 @@
|
||||
namespace SilverStripe\Security\Tests\MemberTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
/**
|
||||
* Extension that adds additional validation criteria
|
||||
*/
|
||||
class SurnameMustMatchFirstNameExtension extends DataExtension implements TestOnly
|
||||
class SurnameMustMatchFirstNameExtension extends Extension implements TestOnly
|
||||
{
|
||||
protected function updatePHP($data, $form)
|
||||
{
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Security\Tests\MemberTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class ValidatorExtension extends DataExtension implements TestOnly
|
||||
class ValidatorExtension extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
protected function updateValidator($validator)
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Security\Tests\MemberTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class ViewingAllowedExtension extends DataExtension implements TestOnly
|
||||
class ViewingAllowedExtension extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
protected function canView($member = null)
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Security\Tests\MemberTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class ViewingDeniedExtension extends DataExtension implements TestOnly
|
||||
class ViewingDeniedExtension extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
protected function canView($member = null)
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class i18nTestModuleExtension extends DataExtension
|
||||
class i18nTestModuleExtension extends Extension
|
||||
{
|
||||
|
||||
public static $db = [
|
||||
|
Loading…
Reference in New Issue
Block a user