Overview

At present we're hard coding loading node 1 — see \Drupal\experience_builder\Controller\SdcController::layout().

Clearly this is not going to be the final solution

Proposed resolution

Add entity type, id (and view mode?) to configuration slice.
Boot the app with these from drupalSettings in Drupal context.
Use those in rawBaseQuery to do slug replacements.
Update the URLs in FE to include the slugs.
Update Drupal route to do the param upcasting.

User interface changes

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

larowlan created an issue. See original summary.

wim leers’s picture

Yes, please!

\Drupal\experience_builder\Controller\SdcController::layout() has this horribleness:

  public function layout(): JsonResponse {
    $first_article = Node::load(1);
    if (!$first_article || $first_article->getType() !== 'article') {
      throw new \LogicException('For now, this assumes node 1 exists and is an article!');
    }

    assert($first_article->field_xb_demo[0] instanceof ComponentTreeItem);

    $tree = $first_article->field_xb_demo[0]->get('tree');
    assert($tree instanceof ComponentTreeStructure);

    $hydrated = $first_article->field_xb_demo[0]->get('hydrated');
    assert($hydrated instanceof ComponentTreeHydrated);
    $hydrated_json = $hydrated->getValue()->getContent();

That's something that this should remove 🤓

(Thanks for creating this issue!)

I'm running into this too over at #3461422: Evolve component instance edit form to become simpler: generate a Field Widget directly.

larowlan’s picture

Status: Active » Needs review
wim leers’s picture

Are these commit messages auto-generated and random? 🤪🤣

wim leers’s picture

Title: Start passing entity type/entity ID context to SdcController from the FE » [PP-1] Start passing entity type/entity ID context to SdcController from the FE
Status: Needs review » Postponed
Related issues: +#3465107: Clarify if local dev on /ui should be possible without Drupal

The MR indicates that this depends on #3465107: Clarify if local dev on /ui should be possible without Drupal, reflecting that.

wim leers’s picture

Status: Postponed » Needs work

#3465107: Clarify if local dev on /ui should be possible without Drupal should land first, but that didn't stop me from reviewing 😊

larowlan’s picture

Are these commit messages auto-generated and random?

Na, I'm just having fun with portlandia quotes

wim leers’s picture

Assigned: Unassigned » bnjmnm
Status: Needs work » Needs review

The back-end changes here (in the controllers + *.routing.yml) make sense.

The front-end changes I'd like to be reviewed by either @bnjmnm or @jessebaker 😊

bnjmnm made their first commit to this issue’s fork.

bnjmnm’s picture

Assigned: bnjmnm » Unassigned

FE looks good

larowlan’s picture

Title: [PP-1] Start passing entity type/entity ID context to SdcController from the FE » Start passing entity type/entity ID context to SdcController from the FE
wim leers’s picture

Status: Needs review » Reviewed & tested by the community

  • Wim Leers committed b404bbf2 on 0.x authored by larowlan
    Issue #3462247 by larowlan, bnjmnm, Wim Leers: Start passing entity type...
wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.