Woocommerce-admin: Navigation: Try to explore less brittle methods of assembling core menu items from post types

Created on 10 Nov 2020  路  4Comments  路  Source: woocommerce/woocommerce-admin

Describe the bug

Right now, in the file src/Features/Navigation/CoreMenu.php we're manually addressing post type objects by index in order to add them to the navigation. As mentioned on this earlier PR this could be fairly brittle and prone to breaking in the future, so we should explore better methods of adding these.

image

navigation

All 4 comments

@psealock @joelclimbsthings What do we consider brittle about this? Is it purely the index used in response? If so, we can update this return an associative array.

It would be great to address this sooner rather than later since I'm planning to use this in a separate repo in https://github.com/woocommerce/woocommerce-subscriptions/pull/3868

@joshuatf Yes, it was primarily the addressing by index that _seemed_ brittle to me, and just a bit less clear in the code, but my guess is that this array is expected to be very stable?

I'd support the change to an associative array, that said.

I agree that sounds like a more stable way to reference the items. Will put out an update- @psealock if you have any other areas of this you were wanting to change, feel free to chime in and I can update the PR accordingly.

+1 to the associative array. It may not have been brittle, but when reading the code it wasn't too clear and _felt_ brittle.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

justinshreve picture justinshreve  路  3Comments

timmyc picture timmyc  路  4Comments

peterfabian picture peterfabian  路  3Comments

jeffstieler picture jeffstieler  路  3Comments

timmyc picture timmyc  路  4Comments