[>=11.4-only] Drop Canvas' `url` computed property from the `link` field type in favor of 11.4's `resolvable_uri`
Drupal 11.4 added the `resolvable_uri` computed property to the `link` field type: - CR: https://www.drupal.org/node/3143736 - issue: https://www.drupal.org/node/3066751 - commit: https://git.drupalcode.org/project/drupal/-/commit/014ef571d6d49536a56f70039c0984f2e4539333 Canvas already did this a year ago in https://www.drupal.org/node/3499279, which currently in `1.x` looks like this: ```php $properties['url'] = DataDefinition::create('string') ->setLabel(new TranslatableMarkup('Resolved URL')) ->setDescription(new TranslatableMarkup('The resolved URL for this link, that can be navigated to by a web browser.')) ->setComputed(TRUE) // The `url` property is computed using the `uri` property, which is // required. Hence this value is guaranteed to exist. ->setRequired(TRUE) // The LinkUrl data type generates a browser-accessible URL (either root- // relative, absolute using HTTP, or absolute using HTTPS). ->addConstraint(UriConstraint::PLUGIN_ID, ['allowReferences' => TRUE]) ->addConstraint(UriSchemeConstraint::PLUGIN_ID, [ 'allowedSchemes' => ['http', 'https'], ]) ->setClass(LinkUrl::class); ``` ⇒ Canvas will need to do the following once it drops support for 11.3: 1. Remove `\Drupal\canvas\TypedData\LinkUrl` 2. Refactor `LinkItemOverride` to become: ```diff diff --git a/src/Plugin/Field/FieldTypeOverride/LinkItemOverride.php b/src/Plugin/Field/FieldTypeOverride/LinkItemOverride.php index 44ac19d05..249c47b89 100644 --- a/src/Plugin/Field/FieldTypeOverride/LinkItemOverride.php +++ b/src/Plugin/Field/FieldTypeOverride/LinkItemOverride.php @@ -28,10 +28,7 @@ class LinkItemOverride extends LinkItem { ]); $properties['uri'] ->addConstraint(UriConstraint::PLUGIN_ID, ['allowReferences' => TRUE]); - $properties['url'] = DataDefinition::create('string') - ->setLabel(new TranslatableMarkup('Resolved URL')) - ->setDescription(new TranslatableMarkup('The resolved URL for this link, that can be navigated to by a web browser.')) - ->setComputed(TRUE) + $properties['resolvable_uri'] // The `url` property is computed using the `uri` property, which is // required. Hence this value is guaranteed to exist. ->setRequired(TRUE) @@ -40,8 +37,7 @@ class LinkItemOverride extends LinkItem { ->addConstraint(UriConstraint::PLUGIN_ID, ['allowReferences' => TRUE]) ->addConstraint(UriSchemeConstraint::PLUGIN_ID, [ 'allowedSchemes' => ['http', 'https'], - ]) - ->setClass(LinkUrl::class); + ]); return $properties; } ``` 3. Update path + update path tests. A completely transparent update path is possible for `ContentTemplate`s, but not for `content-entity-reference` props: those will need logic changes to the JS code consuming it.
issue