Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Change NavItem class API to be fluent instead of readonly #1574

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva commented Feb 19, 2024

This is part of HydePHP v2.x via #1568

A breaking change here is that the NavItem properties are no longer public. Instead they must be used through (already existing) accessors. While this adds extra boilerplate and inconvenience, it also allows us to open up the class data to being edited, the reason we protect the properties is so that we can control the data being added for a consistent and predictable state.

How to upgrade:

Simply replace any usage where you manually called a property with its accessor. (see the file diff for an example)

use Hyde\Framework\Features\Navigation\NavItem;

$item = new NavItem();

$item->destination => $item->getDestination(); 
$item->label => $item->getLabel(); 
$item->priority => $item->getPriority(); 
$item->group => $item->getGroup(); 
$item->children => $item->getChildren(); 

Copy link

codecov bot commented Feb 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b018e7d) 100.00% compared to head (482ac8a) 100.00%.

Additional details and impacted files
@@                        Coverage Diff                        @@
##             improved-navigation-internals     #1574   +/-   ##
=================================================================
  Coverage                           100.00%   100.00%           
- Complexity                            1761      1762    +1     
=================================================================
  Files                                  184       184           
  Lines                                 4767      4769    +2     
=================================================================
+ Hits                                  4767      4769    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@caendesilva caendesilva force-pushed the change-navitem-class-api-to-be-fluent-instead-of-readonly branch from 9a8a5c6 to 5fa2bb2 Compare February 19, 2024 13:37
@caendesilva caendesilva force-pushed the change-navitem-class-api-to-be-fluent-instead-of-readonly branch from c7800e5 to d51186d Compare February 19, 2024 14:35
@caendesilva caendesilva marked this pull request as ready for review February 19, 2024 14:48
@caendesilva caendesilva merged commit 35c1400 into improved-navigation-internals Feb 19, 2024
7 checks passed
@caendesilva caendesilva deleted the change-navitem-class-api-to-be-fluent-instead-of-readonly branch February 19, 2024 14:54
@caendesilva caendesilva mentioned this pull request Jun 27, 2024
99 tasks
@caendesilva caendesilva added this to the v2 milestone Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant