Add Closure support to items() for lazy evaluation#148
Add Closure support to items() for lazy evaluation#148WarLikeLaux wants to merge 6 commits intoyiisoft:masterfrom
Closure support to items() for lazy evaluation#148Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #148 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 289 292 +3
===========================================
Files 8 8
Lines 911 914 +3
===========================================
+ Hits 911 914 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
# Conflicts: # tests/Breadcrumbs/BreadcrumbsTest.php
This reverts commit 52328ad.
samdark
left a comment
There was a problem hiding this comment.
Should be documented with an example on why/when it's needed.
Added docs and fixed the changelog number. While writing the documentation I realized the main use case I had in mind (DI widget definitions) doesn't actually work well in practice. With Yii3's If you think this feature doesn't carry its weight, I'm fine with closing the PR. |
What does this PR do?
Adds
Closuresupport toitems()inBreadcrumbs,Dropdown, andMenufor lazy evaluation.When a widget is configured via DI container, items are defined before runtime data (repositories, current user, locale) is available. Passing a
Closuredefers item resolution untilrender()is called.Array input works exactly as before.
No BC break: the
items()parameter type is widened fromarraytoarray|Closure, so all existing calls remain valid.