diff --git a/_config.php b/_config.php index 9e519d4a..71c7914c 100644 --- a/_config.php +++ b/_config.php @@ -5,5 +5,4 @@ // Avoid creating global variables call_user_func(function () { - }); diff --git a/src/Extensions/AjaxField.php b/src/Extensions/AjaxField.php index 7764c65c..de9e3ad6 100644 --- a/src/Extensions/AjaxField.php +++ b/src/Extensions/AjaxField.php @@ -4,6 +4,7 @@ use SilverStripe\Core\Extension; use SilverStripe\Forms\FormField; +use SilverStripe\Dev\Deprecation; /** * Tweak fields that need to be served through the DynamicLink form schema and need to be able to receive AJAX calls. @@ -11,9 +12,19 @@ * For example the TreeDropdownField need to be able to receive AJAX request to fetch the list of available SiteTrees. * * This is a bit hackish. There's probably a less dumb way of doing this. + * + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ class AjaxField extends Extension { + public function __construct() + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); + parent::__construct(); + } + public function updateLink(&$link, $action) { /** @var FormField $owner */ diff --git a/src/Extensions/FormFactoryExtension.php b/src/Extensions/FormFactoryExtension.php index 1491f924..0bf10abb 100644 --- a/src/Extensions/FormFactoryExtension.php +++ b/src/Extensions/FormFactoryExtension.php @@ -8,14 +8,24 @@ use SilverStripe\Forms\FormAction; use SilverStripe\LinkField\Form\FormFactory; use SilverStripe\LinkField\Models\Link; +use SilverStripe\Dev\Deprecation; /** * Enhance the insert / edit link button label to match the model data state * * @method FormFactory getOwner() + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ class FormFactoryExtension extends Extension { + public function __construct() + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); + parent::__construct(); + } + /** * Extension point in @see FormFactory::getFormActions() * diff --git a/src/Extensions/LeftAndMain.php b/src/Extensions/LeftAndMain.php index d1173a3d..a19760f6 100644 --- a/src/Extensions/LeftAndMain.php +++ b/src/Extensions/LeftAndMain.php @@ -4,12 +4,23 @@ use SilverStripe\Core\Extension; use SilverStripe\LinkField\Type\Registry; +use SilverStripe\Dev\Deprecation; /** * Register a new Form Schema in LeftAndMain. + * + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ class LeftAndMain extends Extension { + public function __construct() + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); + parent::__construct(); + } + public function init() { // Get the Link Registry to load all the JS requirements for managing Links. diff --git a/src/Extensions/ModalController.php b/src/Extensions/ModalController.php index 4df18011..a65c5775 100644 --- a/src/Extensions/ModalController.php +++ b/src/Extensions/ModalController.php @@ -12,12 +12,15 @@ use SilverStripe\LinkField\Models\Link; use SilverStripe\LinkField\Type\Registry; use SilverStripe\ORM\DataObject; +use SilverStripe\Dev\Deprecation; /** * Extensions to apply to ModalController so it knows how to handle the DynamicLink action. * * This action receive a link type key and some link data as a JSON string and retrieve a Form Schema for a * specific Link Type. + * + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ class ModalController extends Extension { @@ -29,6 +32,14 @@ class ModalController extends Extension 'DynamicLink', ]; + public function __construct() + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); + parent::__construct(); + } + /** * Builds and returns the external link form * diff --git a/src/Form/FormFactory.php b/src/Form/FormFactory.php index e9f57f5c..f85981c3 100644 --- a/src/Form/FormFactory.php +++ b/src/Form/FormFactory.php @@ -7,12 +7,22 @@ use SilverStripe\Forms\HiddenField; use SilverStripe\LinkField\Type\Type; use SilverStripe\ORM\DataObject; +use SilverStripe\Dev\Deprecation; /** * Create Form schema for the LinkField based on a key provided by the request. + * + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ class FormFactory extends LinkFormFactory { + public function __construct() + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); + } + protected function getFormFields($controller, $name, $context) { /** @var Type $type */ diff --git a/src/Form/JsonField.php b/src/Form/JsonField.php index 4f7ad0b6..b3b3ce7e 100644 --- a/src/Form/JsonField.php +++ b/src/Form/JsonField.php @@ -7,17 +7,28 @@ use SilverStripe\LinkField\JsonData; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObjectInterface; +use SilverStripe\Dev\Deprecation; /** * Field designed to edit complex data passed as a JSON string. Other FormFields can be built on top of this one. * * It will output a hidden input with serialize JSON Data. + * + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ abstract class JsonField extends FormField { protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_CUSTOM; protected $inputType = 'hidden'; + public function __construct($name, $title = null, $value = null) + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); + parent::__construct($name, $title, $value); + } + public function setValue($value, $data = null) { if ($value && $value instanceof JsonData) { diff --git a/src/GraphQL/LinkDescriptionResolver.php b/src/GraphQL/LinkDescriptionResolver.php index 2259f25d..d1cf704d 100644 --- a/src/GraphQL/LinkDescriptionResolver.php +++ b/src/GraphQL/LinkDescriptionResolver.php @@ -6,9 +6,20 @@ use InvalidArgumentException; use SilverStripe\GraphQL\Schema\DataObject\Resolver; use SilverStripe\LinkField\Type\Registry; +use SilverStripe\Dev\Deprecation; +/** + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it + */ class LinkDescriptionResolver extends Resolver { + public function __construct() + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); + } + public static function resolve($obj, $args = [], $context = [], ?ResolveInfo $info = null) { $data = json_decode($args['dataStr'], true); diff --git a/src/GraphQL/LinkTypeResolver.php b/src/GraphQL/LinkTypeResolver.php index a61f28f1..1da94930 100644 --- a/src/GraphQL/LinkTypeResolver.php +++ b/src/GraphQL/LinkTypeResolver.php @@ -7,9 +7,20 @@ use SilverStripe\GraphQL\Schema\DataObject\Resolver; use SilverStripe\LinkField\Type\Registry; use SilverStripe\LinkField\Type\Type; +use SilverStripe\Dev\Deprecation; +/** + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it + */ class LinkTypeResolver extends Resolver { + public function __construct() + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); + } + public static function resolve($obj, $args = [], $context = [], ?ResolveInfo $info = null) { if (isset($args['keys']) && !is_array($args['keys'])) { diff --git a/src/JsonData.php b/src/JsonData.php index 89ba7201..c2521da8 100644 --- a/src/JsonData.php +++ b/src/JsonData.php @@ -6,6 +6,8 @@ /** * An object that can be serialized and deserialized to JSON. + * + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ interface JsonData extends JsonSerializable { diff --git a/src/Models/EmailLink.php b/src/Models/EmailLink.php index 410455db..c0398716 100644 --- a/src/Models/EmailLink.php +++ b/src/Models/EmailLink.php @@ -4,6 +4,7 @@ use SilverStripe\Forms\EmailField; use SilverStripe\Forms\FieldList; +use SilverStripe\Dev\Deprecation; /** * A link to an Email address. @@ -18,8 +19,14 @@ class EmailLink extends Link 'Email' => 'Varchar(255)', ]; + /** + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use getDescription() instead + */ public function generateLinkDescription(array $data): string { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use getDescription() instead.'); + }); return isset($data['Email']) ? $data['Email'] : ''; } diff --git a/src/Models/ExternalLink.php b/src/Models/ExternalLink.php index c51fb50c..5e4a2f5f 100644 --- a/src/Models/ExternalLink.php +++ b/src/Models/ExternalLink.php @@ -2,6 +2,8 @@ namespace SilverStripe\LinkField\Models; +use SilverStripe\Dev\Deprecation; + /** * A link to an external URL. * @@ -15,8 +17,14 @@ class ExternalLink extends Link 'ExternalUrl' => 'Varchar', ]; + /** + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use getDescription() instead + */ public function generateLinkDescription(array $data): string { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use getDescription() instead.'); + }); return isset($data['ExternalUrl']) ? $data['ExternalUrl'] : ''; } diff --git a/src/Models/FileLink.php b/src/Models/FileLink.php index 0d40b933..28d00999 100644 --- a/src/Models/FileLink.php +++ b/src/Models/FileLink.php @@ -3,6 +3,7 @@ namespace SilverStripe\LinkField\Models; use SilverStripe\Assets\File; +use SilverStripe\Dev\Deprecation; /** * A link to a File track in asset-admin @@ -18,8 +19,14 @@ class FileLink extends Link 'File' => File::class, ]; + /** + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use getDescription() instead + */ public function generateLinkDescription(array $data): string { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use getDescription() instead.'); + }); $fileId = $data['FileID'] ?? null; if (!$fileId) { @@ -31,8 +38,14 @@ public function generateLinkDescription(array $data): string return $file?->getFilename() ?? ''; } + /** + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use getLinkTypeHandlerName() instead + */ public function LinkTypeHandlerName(): string { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use getLinkTypeHandlerName() instead.'); + }); return 'InsertMediaModal'; } diff --git a/src/Models/Link.php b/src/Models/Link.php index 87d2de0f..5d77ee5f 100644 --- a/src/Models/Link.php +++ b/src/Models/Link.php @@ -16,6 +16,7 @@ use SilverStripe\ORM\DataObject; use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\View\Requirements; +use SilverStripe\Dev\Deprecation; /** * A Link Data Object. This class should be a subclass, and you should never directly interact with a plain Link @@ -40,30 +41,60 @@ class Link extends DataObject implements JsonData, Type */ private ?string $linkType = null; + /** + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it + */ public function defineLinkTypeRequirements() { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it.'); + }); Requirements::add_i18n_javascript('silverstripe/linkfield:client/lang', false, true); Requirements::javascript('silverstripe/linkfield:client/dist/js/bundle.js'); Requirements::css('silverstripe/linkfield:client/dist/styles/bundle.css'); } + /** + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use getLinkTypeHandlerName() instead + */ public function LinkTypeHandlerName(): string { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use getLinkTypeHandlerName() instead.'); + }); return 'FormBuilderModal'; } + /** + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use getDescription() instead + */ public function generateLinkDescription(array $data): string { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use getDescription() instead'); + }); return ''; } + /** + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use getMenuTitle() instead + */ public function LinkTypeTile(): string { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use getMenuTitle() instead.'); + }); return $this->i18n_singular_name(); } + /** + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it + */ public function scaffoldLinkFields(array $data): FieldList { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it.'); + }); return $this->getCMSFields(); } @@ -115,9 +146,13 @@ public function getCMSCompositeValidator(): CompositeValidator * We use this to work with an in-memory only field * * @param $value + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ public function saveLinkType($value) { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it.'); + }); $this->linkType = $value; } @@ -133,8 +168,14 @@ public function onBeforeWrite(): void parent::onBeforeWrite(); } + /** + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it + */ function setData($data): JsonData { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it.'); + }); if (is_string($data)) { $data = json_decode($data, true); @@ -184,8 +225,14 @@ function setData($data): JsonData return $jsonData; } + /** + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it + */ public function jsonSerialize(): mixed { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it.'); + }); $typeKey = Registry::singleton()->keyByClassName(static::class); if (!$typeKey) { @@ -205,8 +252,14 @@ public function jsonSerialize(): mixed return $data; } + /** + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it + */ public function loadLinkData(array $data): JsonData { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it.'); + }); $link = new static(); foreach ($data as $key => $value) { @@ -243,9 +296,13 @@ public function getURL(): string * Get all link types except the generic one * * @throws ReflectionException + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use SilverStripe\LinkField\Services\LinkTypeService::generateAllLinkTypes() instead */ private function getLinkTypes(): array { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use SilverStripe\LinkField\Services\LinkTypeService::generateAllLinkTypes() instead.'); + }); $classes = ClassInfo::subclassesFor(self::class); $types = []; diff --git a/src/Models/PhoneLink.php b/src/Models/PhoneLink.php index 855e3b1c..4942e8ed 100644 --- a/src/Models/PhoneLink.php +++ b/src/Models/PhoneLink.php @@ -2,6 +2,8 @@ namespace SilverStripe\LinkField\Models; +use SilverStripe\Dev\Deprecation; + /** * A link to a phone number * @@ -15,8 +17,14 @@ class PhoneLink extends Link 'Phone' => 'Varchar(255)', ]; + /** + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use getDescription() instead + */ public function generateLinkDescription(array $data): string { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use getDescription() instead'); + }); return isset($data['Phone']) ? $data['Phone'] : ''; } diff --git a/src/Models/SiteTreeLink.php b/src/Models/SiteTreeLink.php index f3f611d8..c6faac51 100644 --- a/src/Models/SiteTreeLink.php +++ b/src/Models/SiteTreeLink.php @@ -8,6 +8,7 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\TextField; use SilverStripe\Forms\TreeDropdownField; +use SilverStripe\Dev\Deprecation; /** * A link to a Page in the CMS @@ -30,8 +31,14 @@ class SiteTreeLink extends Link 'Page' => SiteTree::class, ]; + /** + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use getDescription() instead + */ public function generateLinkDescription(array $data): string { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use getDescription() instead.'); + }); $pageId = $data['PageID'] ?? null; if (!$pageId) { diff --git a/src/ORM/DBJson.php b/src/ORM/DBJson.php index 9e6391b1..d05cd0f0 100644 --- a/src/ORM/DBJson.php +++ b/src/ORM/DBJson.php @@ -6,15 +6,20 @@ use SilverStripe\LinkField\JsonData; use SilverStripe\ORM\DB; use SilverStripe\ORM\FieldType\DBField; +use SilverStripe\Dev\Deprecation; /** * Represents a DBField storing a JSON string + * + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ class DBJson extends DBField { - public function __construct($name = null, $defaultVal = []) { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); $this->defaultVal = is_array($defaultVal) ? $defaultVal : []; parent::__construct($name); diff --git a/src/ORM/DBLink.php b/src/ORM/DBLink.php index a5889434..baa88f13 100644 --- a/src/ORM/DBLink.php +++ b/src/ORM/DBLink.php @@ -5,12 +5,23 @@ use SilverStripe\LinkField\Type\Registry; use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\LinkField\Form\LinkField; +use SilverStripe\Dev\Deprecation; /** * Represent Link object stored as a JSON string + * + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ class DBLink extends DBJson { + public function __construct($name = null, $defaultVal = []) + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS); + }); + parent::__construct($name, $defaultVal); + } + /** * Load the link data into a singleton Link Object * diff --git a/src/Type/Registry.php b/src/Type/Registry.php index 152138ea..7c85b86f 100644 --- a/src/Type/Registry.php +++ b/src/Type/Registry.php @@ -8,9 +8,12 @@ use SilverStripe\Core\Extensible; use SilverStripe\Core\Injector\Injectable; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\Deprecation; /** * Manage the list of known link types + * + * @deprecated 3.0.0 Will be removed in linkfield v4 which will use SilverStripe\LinkField\Services\LinkTypeService instead */ class Registry { @@ -18,6 +21,13 @@ class Registry use Extensible; use Injectable; + public function __construct() + { + Deprecation::withNoReplacement(function () { + Deprecation::notice('3.0.0', 'Will be removed in linkfield v4 which will use SilverStripe\LinkField\Services\LinkTypeService instead.', Deprecation::SCOPE_CLASS); + }); + } + private static $types = []; /** diff --git a/src/Type/Type.php b/src/Type/Type.php index 1d0cb428..9a29d161 100644 --- a/src/Type/Type.php +++ b/src/Type/Type.php @@ -7,6 +7,8 @@ /** * Define a link type that can be edited in Link Field + * + * @deprecated 3.0.0 Will be removed without equivalent functionality to replace it */ interface Type {