Skip to content

Commit

Permalink
API Add deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Apr 3, 2024
1 parent 7a16b8b commit 1c3f266
Show file tree
Hide file tree
Showing 20 changed files with 217 additions and 2 deletions.
1 change: 0 additions & 1 deletion _config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@

// Avoid creating global variables
call_user_func(function () {

});
11 changes: 11 additions & 0 deletions src/Extensions/AjaxField.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,27 @@

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.
*
* 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 */
Expand Down
10 changes: 10 additions & 0 deletions src/Extensions/FormFactoryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
*
Expand Down
11 changes: 11 additions & 0 deletions src/Extensions/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions src/Extensions/ModalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
*
Expand Down
10 changes: 10 additions & 0 deletions src/Form/FormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
11 changes: 11 additions & 0 deletions src/Form/JsonField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions src/GraphQL/LinkDescriptionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/GraphQL/LinkTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
2 changes: 2 additions & 0 deletions src/JsonData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
7 changes: 7 additions & 0 deletions src/Models/EmailLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use SilverStripe\Forms\EmailField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Dev\Deprecation;

/**
* A link to an Email address.
Expand All @@ -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'] : '';
}

Expand Down
8 changes: 8 additions & 0 deletions src/Models/ExternalLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace SilverStripe\LinkField\Models;

use SilverStripe\Dev\Deprecation;

/**
* A link to an external URL.
*
Expand All @@ -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'] : '';
}

Expand Down
13 changes: 13 additions & 0 deletions src/Models/FileLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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';
}

Expand Down
Loading

0 comments on commit 1c3f266

Please sign in to comment.