Skip to content

Instantly share code, notes, and snippets.

@enko
Created July 19, 2012 10:26
Show Gist options
  • Select an option

  • Save enko/3142905 to your computer and use it in GitHub Desktop.

Select an option

Save enko/3142905 to your computer and use it in GitHub Desktop.
Menu
<?php
class Actions {
public function doStuff() {
}
}
class Menu {
var items = array(); // contains MenuItems or Menu (SubMenus!)
}
class MenuItem {
var $menu = null;
var $action = null; // callback
function __construct(Menu $menu) {
$this->menu = $menu;
}
}
$action = new Actions()
$menu = new Menu();
$mi = new MenuItem($menu);
$mi->action = $action->doStuff;
$foo->items[] = $mi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment