Prove any prop shape can be made to work if a contrib module implements `hook_storage_prop_shape_alter()` and populates it
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3515624. --> Reported by: [wim leers](https://www.drupal.org/user/99777) Related to !367 >>> <h3 id="overview">Overview</h3> <p>@lauriii has articulated that the following contrib modules need to be supported in <code>1.0</code>:</p> <ul> <li><a href="http://drupal.org/project/linkit">http://drupal.org/project/linkit</a> &rarr; additional widget for the <code>link</code> field type </li><li><a href="https://www.drupal.org/project/focal_point">https://www.drupal.org/project/focal_point</a> &rarr; new field type + field widget </li></ul> <p>The first one is not a problem: for that we'd use the already-existing <code>hook_storage_prop_shape_alter()</code>. See <code>xb_test_storage_prop_shape_alter_storage_prop_shape_alter()</code> for an example.</p> <p><del>But the second one is a problem: our current shape matching infrastructure (see <code>\Drupal\experience_builder\JsonSchemaInterpreter\SdcPropJsonSchemaType::computeStorablePropShape()</code>) does not support adding matches (field types+widgets) for <em>additional</em> shapes.</del> &rarr; wrong per #12</p> <p>Another realistic (but out of scope) example: the <code>color</code> field type + widget at <a href="https://git.drupalcode.org/project/color_field/-/tree/3.0.x/src/Plugin/Field?ref_type=heads">https://git.drupalcode.org/project/color_field/-/tree/3.0.x/src/Plugin/Field?ref_type=heads</a>. For that example, we'd need an SDC with a prop whose schema looks like this:</p> <pre>type: string<br>pattern: ^#?(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$</pre><p> (per <a href="https://git.drupalcode.org/project/color_field/-/blob/3.0.x/src/Plugin/Field/FieldType/ColorFieldType.php?ref_type=heads#L93">https://git.drupalcode.org/project/color_field/-/blob/3.0.x/src/Plugin/Field/FieldType/ColorFieldType.php?ref_type=heads#L93</a>)</p> <p>This would automatically be matched with the Color field type with zero changes to XB right now AFAICT, thanks to</p> <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; array_key_exists('pattern', $schema) =&gt; new DataTypeShapeRequirement('Regex', ['pattern' =&gt; '/' . str_replace('/', '\/',$schema['pattern']) . '/']),</pre><p> in <code>\Drupal\experience_builder\JsonSchemaInterpreter\SdcPropJsonSchemaType::toDataTypeShapeRequirements()</code>. But that&rsquo;ll only work for <code>DynamicPropSource</code>s, so for existing field definitions on existing content entity types.</p> <p><del>&#128721; The blocker: <code>hook_storage_prop_shape_alter()</code> only can alter the <em>existing</em> hard-coded shape matches in <code>SdcPropJsonSchemaType::computeStorablePropShape()</code>, it cannot add new ones.</del> &rarr; wrong per #12, disproven by tests.</p> <h3 id="proposed-resolution">Proposed resolution</h3> <p>Add test coverage. See MR commit messages, read them in order: they provide the right context. There are few commits.</p> <h3 id="ui-changes">User interface changes</h3> <p>None.</p> > Related issue: [Issue #3552659](https://www.drupal.org/node/3552659) > Related issue: [Issue #3450496](https://www.drupal.org/node/3450496)
issue