mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Revert deprecation of Object::add_extension() usage
This reverts commit 14b997eea3
.
Its just not practical to use the Config API as it stands,
the add_extension() wrapper does more than just a Config->update().
Most use cases can be covered via YML, but any conditional
additions (e.g. in unit tests) can still benefit from the
add_extensions() shorthand.
This commit is contained in:
parent
16c7235942
commit
ae09301c8c
@ -440,24 +440,23 @@ abstract class Object {
|
||||
|
||||
/**
|
||||
* Add an extension to a specific class.
|
||||
*
|
||||
* The preferred method for adding extensions is through YAML config,
|
||||
* since it avoids autoloading the class, and is easier to override in
|
||||
* more specific configurations.
|
||||
*
|
||||
* As an alternative, extensions can be added to a specific class
|
||||
* directly in the {@link Object::$extensions} array.
|
||||
* See {@link SiteTree::$extensions} for examples.
|
||||
* Keep in mind that the extension will only be applied to new
|
||||
* instances, not existing ones (including all instances created through {@link singleton()}).
|
||||
*
|
||||
* @deprecated 3.2 Use YAML config instead, see
|
||||
* http://doc.silverstripe.org/framework/en/trunk/reference/dataextension
|
||||
* @see http://doc.silverstripe.org/framework/en/trunk/reference/dataextension
|
||||
* @param string $class 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" or "Translatable('Param')"
|
||||
*/
|
||||
public static function add_extension($classOrExtension, $extension = null) {
|
||||
Deprecation::notice(
|
||||
'3.2',
|
||||
'Use YAML config instead, see http://doc.silverstripe.org/framework/en/trunk/reference/dataextension'
|
||||
);
|
||||
|
||||
if(func_num_args() > 1) {
|
||||
$class = $classOrExtension;
|
||||
} else {
|
||||
|
@ -450,4 +450,3 @@ you can enable those warnings and future-proof your code already.
|
||||
* Hard limit displayed pages in the CMS tree to `500`, and the number of direct children to `250`,
|
||||
to avoid excessive resource usage. Configure through `Hierarchy.node_threshold_total` and `
|
||||
Hierarchy.node_threshold_leaf`. Set to `0` to show tree unrestricted.
|
||||
* Deprecated `Object::add_extension()`, use YAML config instead, see [docs](http://doc.silverstripe.org/framework/en/trunk/reference/dataextension)
|
@ -33,12 +33,9 @@ In order to active this extension, you'd add the following to your [config.yml](
|
||||
- MyMemberExtension
|
||||
|
||||
Alternatively, you can add extensions through PHP code as well (in your `config.php` file),
|
||||
which means they can be used in conditional configuration.
|
||||
which means they can be used in conditional configuration.
|
||||
|
||||
:::php
|
||||
// Preferred notation: Through the Config API
|
||||
Config::inst()->update('Member', 'extensions', array('MyMemberExtension'));
|
||||
// Legacy notation: Through static class access
|
||||
Member::add_extension('MyMemberExtension');
|
||||
|
||||
## Implementation
|
||||
|
Loading…
Reference in New Issue
Block a user