- Issue created by @just_like_good_vibes
- 🇫🇷France just_like_good_vibes PARIS
we found the solution.
one needs to implement
function ui_patterns_ds_preprocess_ds_entity_view(&$variables) { if (isset($variables['content']) && isset($variables['content']['#entity']) && isset($variables['content']['#source_contexts']) && is_array($variables['content']['#source_contexts']) && !isset($variables['content']['#source_contexts']["entity"])) { $variables['content']['#source_contexts']["entity"] = \Drupal\Core\Plugin\Context\EntityContext::fromEntity($variables['content']['#entity']); } }
- 🇺🇸United States dalemoore
This partially solves the issue for me. I put the code @just_like_good_vibes included above directly into a custom module, installed it, and I no longer get ContextException errors on the front end, but I do still get them in Layout Builder.
Steps:
- Put the code above in a custom module, or in the code for this new module, whatever you have to do to get it the codebase :)
- Create a block type, for example, Alert, and add a field on it of List (text) type called Variant. Add some variant types to the field list, e.g., default|Default, primary|Primary, danger|Danger, etc. and save... can add other fields too like Body to populate the alert slot.
- In the Alert block type, select an Alert component from the SDCs in the layout settings. Map the Variant field to the Variant prop.
- Go to a content type, like Page, and enable Layout Builder and add a block of the Alert block type to it, and select one of the variants and save the layout.
- The Alert block will have the proper variant on the frontend of the site, but in Layout Builder for the page content type, it won't. You'll still get the ContextExceptions in the logs.
- 🇫🇷France just_like_good_vibes PARIS
Hello, thanks for reporting the issue, much value, we indeed to carefully investigate more.
i will update the proposed solution soon -
sharique →
committed f18056c4 on 1.0.x
Issue #3501396 by just_like_good_vibes: ContextException with entity,...
-
sharique →
committed f18056c4 on 1.0.x
- Merge request !2Issue #3501396 by just_like_good_vibes, sharique: ContextException with entity → (Merged) created by just_like_good_vibes
-
just_like_good_vibes →
committed 36763aab on 1.0.x
Issue #3501396 by just_like_good_vibes, sharique: ContextException with...
-
just_like_good_vibes →
committed 36763aab on 1.0.x
- 🇫🇷France just_like_good_vibes PARIS
Hello @dalemoore, It should be fixed now :)
Automatically closed - issue fixed for 2 weeks with no activity.