Problem/Motivation

Until now, we are the only ones using the JSON Schema reference system with SDC prop definitions. But core may introduce a similar mechanism, inspired from ours: #3352063: Allow schema references in Single Directory Component prop schemas

Proposed resolution

So, we need to test if "ui-patterns" is the scheme of the URL before doing any processing.

Also, let's check if the prop type exists.

API changes

This is not a breaking change.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

oldeb’s picture

Assigned: Unassigned » oldeb
oldeb’s picture

Status: Active » Closed (works as designed)

Check for correct scheme is already done in the ComponentPluginManager::annotateProps method.

PropType availiblity is done by the PluginManagerBase::createInstance method.

pdureau’s picture

Check for correct scheme is already done in the ComponentPluginManager::annotateProps method.

It is not the same check .Sure, it is technically the same, but not at the same moment for the same purpose.

Anyway, the check is already done, indeed, by the stream_wrapper service manager, because of the tags from the service definition;

  ui_patterns.schema_stream_wrapper:
    class: Drupal\ui_patterns\SchemaManager\StreamWrapper
    arguments:
      - "@plugin.manager.ui_patterns_prop_type"
    tags:
      - { name: stream_wrapper, scheme: ui-patterns }  

So, instead of doing the check again, maybe a little ocmment to explain why it is not necessary

PropType availiblity is done by the PluginManagerBase::createInstance method.

What will happen if we do ui-patterns://this_is_not_a_prop_type?
Because we have $plugin->getSchema() later in the stream wrapper?

https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/SchemaMa...

oldeb’s picture

When an incorrect scheme is passed : an error is thrown. This should never happen since it's checked by the ComponentPluginManager before calling file_get_contents and, like you said, the streamwrapper is always called with the correct scheme because of the tags in the service definition.

When an incorrect plugin is passed, the file_get_contents return a string with an empty array : "[]"
So there is no error, the schema is just empty.