v1.php 852 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace zin;
  3. require_once dirname(__DIR__) . DS . 'actionitem' . DS . 'v1.php';
  4. class menu extends wg
  5. {
  6. /**
  7. * @var mixed[]
  8. */
  9. protected static $defineProps = array(
  10. 'items?:array'
  11. );
  12. public function onBuildItem($item)
  13. {
  14. if(!($item instanceof item)) $item = item(set($item));
  15. return actionItem
  16. (
  17. set('name', 'menu'),
  18. set('outerClass', 'item'),
  19. inherit($item)
  20. );
  21. }
  22. /**
  23. * @return builder
  24. */
  25. protected function build()
  26. {
  27. $items = $this->prop('items');
  28. return h::menu
  29. (
  30. setClass('menu'),
  31. set($this->getRestProps()),
  32. is_array($items) ? array_map(array($this, 'onBuildItem'), $this->prop('items')) : null,
  33. $this->children()
  34. );
  35. }
  36. }