Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
See #2932462-67: Add EntityContextDefinition for the 80% use case
Proposed resolution
Delegate all constraint-related methods to the ECD.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#16 | 2986033_16_11_interdiff.txt | 1.22 KB | mtodor |
#16 | 2986033_16_FAIL.patch | 2.39 KB | mtodor |
#16 | 2986033_16.patch | 4.68 KB | mtodor |
#11 | 2986033_11.patch | 4.72 KB | mtodor |
#11 | 2986033_11_TEST_ONLY.patch | 2.43 KB | mtodor |
Comments
Comment #2
tim.plunkettThe
$context_definition->addConstraint('Bundle', [$bundle]);
call in FieldBlockDeriver was having no effect.Comment #3
tim.plunkettComment #4
mtodor CreditAttribution: mtodor at Thunder commentedI have applied this patch and the problem still persists for me.
Here are steps how to reproduce:
layout_builder
Landing Page
body
field from itAllow each content item to have its layout customized.
=> SaveLayout
tab+ Add Block
Comment #5
mtodor CreditAttribution: mtodor at Thunder commentedI have quickly added tests if that can help.
Comment #7
tim.plunkettThanks @mtodor!
If I clear the caches and then immediately refresh
/layout_builder/choose/block/overrides/node.1/0/content
, I see the correct list.On subsequent refreshes, it breaks again.
Which means we're losing the constraints.
Cleaned up the test a bit.
Comment #9
tim.plunkettUgh, that passed for me locally :(
Comment #11
mtodor CreditAttribution: mtodor at Thunder commented@tim.plunkett Test works for me locally too .. :)
Btw. I have checked code from #7 and it works fine.
Additionally, I have checked fail for #5 and it fails in the wrong place, so TestBot doesn't like us.
Here is first try to get in the better relationship with TestBot.
P.S. I have selected 8.6.x for testing because I developed on it.
Comment #12
mtodor CreditAttribution: mtodor at Thunder commentedComment #14
tim.plunkettOh! Misunderstood the fail. That makes sense, since the testbot installs in a subdirectory, and the URL will be different.
Comment #15
phenaproximaExtremely minor nits: $validLinks should be $valid_links (same with $invalidLinks), and we can use assertCount() rather than assertEquals() to validate the counts.
Additionally, I think that CSS selectors are easier to read than XPath queries, so I think we could use
a[href*="field_block%3Anode%3A%bundle_with_layout_overrides%3Abody"]
instead of the XPath.Otherwise, I think this is good to go.
Comment #16
mtodor CreditAttribution: mtodor at Thunder commentedHere is the patch that addresses review from #15.
Well, for me XPath is more readable (because I have worked with it a lot in previous jobs) and additionally, our tests are converting CSS to XPath - so I need to take a look at Symfony documentation - https://github.com/symfony/css-selector/blob/v3.4.12/Tests/XPath/TranslatorTest.php :D
I have changed a bit suggested selector from
a[href*="..."]
toa[href$="..."]
, it's a bit more strict.Comment #17
phenaproximaThanks for changing that, @mtodor :) I appreciate it. RTBC once green on all backends.
Comment #19
tim.plunkettComment #20
tim.plunkettThis should go into 8.6.x to avoid a regression.
Comment #21
alexpottCommitted and pushed 52aa9a23d9 to 8.7.x and a8d7a55139 to 8.6.x. Thanks!
Can we get a follow-up to fix this documentation - having an @see that points to the issue that added the code is weird - that's what git blame is for. Also just listed where it is used in @see is bound to get out-of-date as it now is. And these
@see ::
don't actually work in PHPStorm and so I guess they don't work on api.drupal.org - so they are pretty pointless.