Clean up menu assembly with intermediate representations #9508

Closed
mrclay opened this Issue Mar 17, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@mrclay
Member

mrclay commented Mar 17, 2016

I think in general menus are too squishy and loosely typed, making it easy for devs to miss, duplicate steps, or do them in the wrong order. We could use types to make sure menus are handled right:

  • Elgg\Menu\List: set of items plus some utility methods (e.g.)
  • Elgg\Menu\Menu: name and list
  • Elgg\Menu\PreparedMenu: name and sections

An elgg()->menus service could have methods to build those up in the particular order we need:

  • build(name, params) calls register, returns Menu
  • prepare(Menu) builds sections, calls prepare, returns PreparedMenu
  • view(PreparedMenu)

None of this would make it impossible to hack those steps if you needed to.

cc @hypeJunction @jdalsem

@hypeJunction

This comment has been minimized.

Show comment
Hide comment
@hypeJunction

hypeJunction Mar 18, 2016

Contributor

SGTM

Contributor

hypeJunction commented Mar 18, 2016

SGTM

mrclay added a commit to mrclay/Elgg-leaf that referenced this issue Mar 20, 2016

feature(menus): adds menu service for more orderly menu construction
A dedicated menu service provides tools for constructing menus such that
hooks and other steps are not forgotten, and not performed more than once.

Fixes #9508
@mrclay

This comment has been minimized.

Show comment
Hide comment
Member

mrclay commented Mar 20, 2016

PR #9522

mrclay added a commit to mrclay/Elgg-leaf that referenced this issue Mar 20, 2016

feature(menus): adds menu service for more orderly menu construction
A dedicated menu service provides tools for constructing menus such that
hooks and other steps are not forgotten, and not performed more than once.

Fixes #9508

mrclay added a commit to mrclay/Elgg-leaf that referenced this issue Mar 20, 2016

feature(menus): adds menu service for more orderly menu construction
A dedicated menu service provides tools for constructing menus such that
hooks and other steps are not forgotten, and not performed more than once.

Fixes #9508

mrclay added a commit to mrclay/Elgg-leaf that referenced this issue Mar 20, 2016

feature(menus): adds menu service for more orderly menu construction
A dedicated menu service provides tools for constructing menus such that
hooks and other steps are not forgotten, and not performed more than once.

Fixes #9508

mrclay added a commit to mrclay/Elgg-leaf that referenced this issue Mar 20, 2016

feature(menus): adds menu service for more orderly menu construction
A dedicated menu service provides tools for constructing menus such that
hooks and other steps are not forgotten, and not performed more than once.

Fixes #9508

mrclay added a commit to mrclay/Elgg-leaf that referenced this issue Mar 20, 2016

feature(menus): adds menu service for more orderly menu construction
A dedicated menu service provides tools for constructing menus such that
hooks and other steps are not forgotten, and not performed more than once.

`elgg()->menus->getMenu` can build a complete menu with all hooks pre-triggered,
or can return a linear menu before the items have been split into sections and
run through the `prepare` hook.

In either case, passing these objects to `elgg_view_menu()` completes the
preparation process before passing the menu to a view.

Fixes #9508

mrclay added a commit to mrclay/Elgg-leaf that referenced this issue Mar 20, 2016

feature(menus): adds menu service for more orderly menu construction
A dedicated menu service provides tools for constructing menus such that
hooks and other steps are not forgotten, and not performed more than once.

`elgg()->menus->getMenu` can build a complete menu with all hooks pre-triggered,
or can return a linear menu before the items have been split into sections and
run through the `prepare` hook.

In either case, passing these objects to `elgg_view_menu()` completes the
preparation process before passing the menu to a view.

Fixes #9508

mrclay added a commit to mrclay/Elgg-leaf that referenced this issue Mar 22, 2016

feature(menus): adds menu service for more orderly menu construction
A dedicated menu service provides tools for constructing menus such that
hooks and other steps are not forgotten, and not performed more than once.

`elgg()->menus->getMenu` builds a complete menu with all hooks pre-triggered,
or `getUnpreparedMenu` can just return a linear menu before the items have been
split into sections and run through the `prepare` hook.

In either case, passing these objects to `elgg_view_menu()` completes the
preparation process before passing the menu to a view.

Fixes #9508

@jdalsem jdalsem closed this in #9522 Mar 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment