[MGNLSITE-38] Provide in SiteFunctions: Nested call to get theme and additonal null handling. Created: 15/Sep/15 Updated: 19/May/22 Resolved: 19/May/22 |
|
| Status: | Closed |
| Project: | Magnolia Site Module |
| Component/s: | api |
| Affects Version/s: | 1.0.2 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Christian Ringele | Assignee: | Unassigned |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Template: |
|
| Patch included: |
Yes
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Date of First Response: |
| Description |
|
When you need the current configured theme you need to retrieve it with two calls:
[#assign currentSite = sitefn.site(content)]
[#assign currentTheme = sitefn.theme(currentSite)]
//Clear, you can also do it in one line of code, but its still two calls:
[#assign currentTheme = sitefn.theme(sitefn.site(content)))]
Which is a bit confusing for beginners. And also its more error prone and less straight forward. It would be easy to provide it in one method fir getting the theme accepting Node, doing the nested call: [#assign currentTheme = sitefn.theme(content)] Would look like this: public Theme theme(Node content) { if(content == null) return null; Site site = this.site(content); return (site == null) ? null : this.theme(site); } I included a patch containing the code, and also a version for ContentMap. Also I added into the patch some missing null handling in: public Theme theme(Site site) { // site.getTheme().getName(); will produce NPE And public Site site(ContentMap content) { // content.getJCRNode(); will produce NPE |
| Comments |
| Comment by Roman Kovařík [ 19/May/22 ] |
|
Hello, This ticket is now marked as closed due to one of the following reasons:
If you are still facing a problem or consider this issue still relevant, please feel free to re-open the ticket and we will reach out to you. Thank you, |