- Issue created by @wim leers
- π§πͺBelgium borisson_ Mechelen, π§πͺ
Validate level: must be between 0 and $this->menuTree->maxDepth()β Range constraint?
Can a range constraint be variable like this, or should we fall back to the same thing with did for weight and say it is somewhere between 0 and PHP_INT_MAX?
- πΊπΈUnited States phenaproxima Massachusetts
$this->menuTree->maxDepth()
Fun fact:
\Drupal\Core\Menu\MenuLinkTree::maxDepth()
calls\Drupal\Core\Menu\MenuTreeStorage::maxDepth()
, which does no computation at all, but merely returns...a constant (\Drupal\Core\Menu\MenuTreeStorage::MAX_DEPTH
).That constant is older than two of my nieces. It was created in #2301239: MenuLinkNG part1 (no UI or conversions): plugins (static + MenuLinkContent) + MenuLinkManager + MenuTreeStorage β and appears to have been completely unchanged since.
So, to get this issue done faster, I propose that we don't even need to worry about having a special constraint to determine the max depth dynamically. Let's just hard-code it, at least for now, based on the value of that constant, which has not been changed in core since it was introduced.
That way, we'll get pretty strong validation done quickly, without a ton of effort, and we could make it a more flexible constraint later in a follow-up.
- πΊπΈUnited States phenaproxima Massachusetts
Wouldn't it be better to make depth optional, aka nullable: true? Then we don't need to assign a special meaning to 0
Not sure we should do that, as it would constitute an API change for...what benefit, exactly? Maybe a separate issue would be better here.
- π§πͺBelgium borisson_ Mechelen, π§πͺ
The analysis in #4 looks great! That means we can do it easily with the same flexibility of constraint we have today. +1 to this approach
- Merge request !11933Update path to convert `depth` setting to NULL β (Closed) created by phenaproxima
- πΊπΈUnited States phenaproxima Massachusetts
Wrote the update path. But it does need an explicit validation test.
- π¬π§United Kingdom longwave UK
Don't we also need a constraint adding to
depth
? - πΊπΈUnited States phenaproxima Massachusetts
Tests written. Just need to test that ol' update path!
- πΊπΈUnited States phenaproxima Massachusetts
And, added an update path test. I think this is reviewable now.
- π§πͺBelgium borisson_ Mechelen, π§πͺ
Tests are green, that's great! I think the new constraint also makes a lot of sense.
There's an upgrade path and the changes to tests also look good. - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Just one minor comment about the deprecation notice linking to a CR instead of an issue nid
Fine to self RTBC - πΊπΈUnited States phenaproxima Massachusetts
Wrote a CR and linked to it from the deprecation message, so back to RTBC per #13.
- π³π±Netherlands bbrala Netherlands
Was going to ask why we are not calling this Depth instead of MaxLinkDepth and coupling to the menu. But seems getting maxDepth in some other way it rather hard. So guess my thoughts are a no-op.
- πΊπΈUnited States phenaproxima Massachusetts
Moving the update path around was a very minor lift, so restoring RTBC here on the assumption that tests will pass.
-
longwave β
committed df9baa95 on 11.x
Issue #3520944 by phenaproxima, wim leers, borisson_, longwave: Make...
-
longwave β
committed df9baa95 on 11.x
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
@longwave the MR was closed but it doesn't look like this was committed/pushed - was that by mistake?