Skip to content

Chore/433 nav interfaces#36

Merged
sbrody merged 4 commits into
mainfrom
chore/433-nav-interfaces
Jul 7, 2026
Merged

Chore/433 nav interfaces#36
sbrody merged 4 commits into
mainfrom
chore/433-nav-interfaces

Conversation

@sbrody

@sbrody sbrody commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description of changes

Introduces interfaces in place of navigation classes. Calls to classes within Navigation.php are replaced with calls to the interface. This will allow us to have multiple implementations of the navigation while keeping the basic structure.

To this end the navigation classes are renamed to illustrate that they are children of the interface parents that focus on a particular functional approach - in this case using page hierarchy to generate nav items.

Tests are updated and new tests added for the interfaces.
...

Checklist

  • Changelog updated
  • If new release: major version tag to be bumped after release (see docs)

sbrody added 3 commits July 7, 2026 11:07
Calls to classes within Navigation.php are replaced with calls
to the interface. This will allow us to have multiple
implementations of the navigation while keeping the basic
structure. To this end the navigation classes are renamed to
illustrate that they are children of the interface parents that
focus on a particular functional approach
Also update tests where classnames have changed or injection
has changed from direct class to interface

@RobjS RobjS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but there's a couple of places where I think we could tighten up the interface definitions to make their intention clearer.


interface ChapterNavigationInterface
{
public function getItems(): array;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could probably tighten this up a little by specifying in a docblock/Psalm comment that this is an array of ChapterNavigationItems.


interface InPageNavigationInterface
{
public function getItems(): array;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, here we could specify that this is an array of InPageNavigationItems.

This tightens up the logic. As a result, a new property of
ChapterNavItems must be created before it can be set in Navigation
@sbrody

sbrody commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

This looks good, but there's a couple of places where I think we could tighten up the interface definitions to make their intention clearer.

Ok makese sense, I have added that in. As a result ChapterNavItem needs a new property, which is also added

@sbrody sbrody requested a review from RobjS July 7, 2026 11:29

@RobjS RobjS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good to me.

One thing to note: the additional subItems property having a default value of an empty array probably means this will need to be a major version bump, because if any existing themes rely on the subItems property only existing if there are subitems, it could cause menus to output incorrect HTML.

@sbrody sbrody merged commit c0438a6 into main Jul 7, 2026
2 checks passed
@sbrody sbrody deleted the chore/433-nav-interfaces branch July 7, 2026 15:04
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.

2 participants