Merge pull request #2991 from creative-commoners/pulls/5/deprecate-sitetreextension

API Deprecate SiteTreeExtension
This commit is contained in:
Guy Sartorelli 2024-08-26 09:57:26 +12:00 committed by GitHub
commit df4bb11f50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,15 +4,29 @@ namespace SilverStripe\CMS\Model;
use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataExtension;
use SilverStripe\Security\Member; use SilverStripe\Security\Member;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Core\Extension;
/** /**
* Plug-ins for additional functionality in your SiteTree classes. * Plug-ins for additional functionality in your SiteTree classes.
* *
* @template T of SiteTree * @template T of SiteTree
* @extends DataExtension<T> * @extends DataExtension<T>
* @deprecated 5.3.0 Subclass SilverStripe\Core\Extension\Extension instead
*/ */
abstract class SiteTreeExtension extends DataExtension abstract class SiteTreeExtension extends DataExtension
{ {
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 called before the page's {@link Versioned::publishSingle()} action is completed * Hook called before the page's {@link Versioned::publishSingle()} action is completed