Overview
Right now if a Content exists for a view mode and the bundle has a Component Tree field the content template will take effect.
This will be problem in #3541000: [META] Content templates UI for 1.0: only nodes, no exposed slots, no replacement for the view mode/display UI as soon as the UI adds a new ContentTemplate but before it is published it will take effect
Proposed resolution
In `\Drupal\experience_builder\EntityHandlers\ContentTemplateAwareViewBuilder::buildComponents` after the component is loaded it should only be used if the status is true.
So something like
$template = ContentTemplate::loadForEntity($entity, $view_mode);
if ($template && $template->status()) {
$displays[$bundle] = $template;
}
\Drupal\Tests\experience_builder\Kernel\NodeTemplatesTest::testOptContentTypeIntoXb should be updated to test a with the status of the template first false, it should not take effect and then once set to true it should take effect.
Bonus
Additionally it would be great if even though ApiLayoutController won't work with ContentTemplate entities until #3541021: Refactor `ApiLayoutController` to support `ContentTemplate`s in this issue we can still update \Drupal\experience_builder\Controller\ApiAutoSaveController::post to set the status to true on publish. \Drupal\Tests\experience_builder\Kernel\ApiAutoSaveControllerTest::testPost will need to be updated to assert that a ContentTemplate actually has it's status updated.We can't use `ApiLayoutController` in this test but we can still add a ContentTemplate entity using \Drupal\experience_builder\AutoSave\AutoSaveManager::saveEntity
User interface changes
None
Issue fork experience_builder-3543188
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
Comment #2
tedbowComment #5
thoward216 commentedComment #6
tedbow@thoward216 I think this is looking good, just need to add the test coverage I just mentioned in the MR comment. thanks!
Comment #7
wim leersComment #8
tedbow@thoward216 and @wimlees a got further in the test but the relieved some other, problems, not with your code, but some things I hadn't thought of.
Working on it
Comment #9
tedbow@wimleers see my last MR comment
Comment #10
wim leersRTBC — with a caveat: please confirm that my understanding at https://git.drupalcode.org/project/experience_builder/-/merge_requests/1... is correct 🙏
Comment #12
wim leersPerfect, thanks, @thoward216! 😊