Lift most logic out of ComponentTreeItem::preSave() and into a new validation constraint

Created on 20 June 2024, 5 months ago
Updated 1 August 2024, 4 months ago

Problem/Motivation

This logic:

    // Validate that each prop source resolves into a value that is considered
    // valid by the destination SDC prop.
    // @todo Move to validation constraint.
    foreach ($component_instance_uuids as $component_instance_uuid) {
      $component_id = $tree->getComponentId($component_instance_uuid);
      $props_values = $this->resolveComponentProps($component_instance_uuid);
      try {
        $component = $this->getComponentPluginManager()->find($component_id);
        $this->getComponentValidator()->validateProps($props_values, $component);
      }
      catch (ComponentNotFoundException $e) {
        throw new \LogicException(sprintf('The component instance with UUID %s uses component %s but does not exist! Put a breakpoint here and figure out why.', $component_instance_uuid, $component_id));
      }
      catch (InvalidComponentException $e) {
        throw new \LogicException(sprintf('The component instance with UUID %s uses component %s and receives some invalid props! Put a breakpoint here and figure out why.', $component_instance_uuid, $component_id));
      }
    }

… belongs in a validation constraint.

It'll:

  1. simplify the field type logic
  2. allow that same logic to be reused in multiple things of 🌱 [META] Configuration management: define needed config entity types Active , starting with the "component" config entity that 📌 "Developer-created components": mark which SDCs should be exposed in XB Fixed introduced

Steps to reproduce

Proposed resolution

Do the above.

If Allow specifying default props values when opting an SDC in for XB Fixed lands before this, its config schema should be updated to use this new validation constraint too.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Component

Code

Created by

🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024