From ae09301c8c3c65f5192698a1439cf7dd4dc86890 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 11 Apr 2013 11:32:31 +0200 Subject: [PATCH] Revert deprecation of Object::add_extension() usage This reverts commit 14b997eea3c2a541fe842025b4f7ff76bd74fba9. 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. --- core/Object.php | 13 ++++++------- docs/en/changelogs/3.1.0.md | 1 - docs/en/reference/dataextension.md | 5 +---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/core/Object.php b/core/Object.php index f04629a7f..602b93b2e 100755 --- a/core/Object.php +++ b/core/Object.php @@ -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 { diff --git a/docs/en/changelogs/3.1.0.md b/docs/en/changelogs/3.1.0.md index d788eff3b..7484f90a5 100644 --- a/docs/en/changelogs/3.1.0.md +++ b/docs/en/changelogs/3.1.0.md @@ -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) \ No newline at end of file diff --git a/docs/en/reference/dataextension.md b/docs/en/reference/dataextension.md index 1162da479..bbb0da421 100644 --- a/docs/en/reference/dataextension.md +++ b/docs/en/reference/dataextension.md @@ -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