Breadcrumb.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\Http\View;
  3. /**
  4. * Description of Breadcrumb
  5. *
  6. * @autor ThurData <info@thrudata.ch>
  7. */
  8. class Breadcrumb
  9. {
  10. /**
  11. * @var array
  12. */
  13. protected $data = [];
  14. public function __construct()
  15. {
  16. }
  17. public function load(array $menu = [], $controller = null, $action = null, array $arrayBreadcrumb = [])
  18. {
  19. if (empty($controller))
  20. {
  21. $controller = key($menu);
  22. }
  23. if ($controller)
  24. {
  25. $this->data[] = [
  26. 'name' => $controller,
  27. 'url' => $menu[strtolower($controller)]['url'] ? : $menu[$controller]['url'],
  28. 'icon' => $menu[strtolower($controller)]['icon'] ? : $menu[$controller]['icon']
  29. ];
  30. }
  31. if ($arrayBreadcrumb)
  32. {
  33. $count = count($arrayBreadcrumb) - 1;
  34. foreach ($arrayBreadcrumb as $number => $breadcrumb)
  35. {
  36. $this->data[] = [
  37. 'name' => $breadcrumb->getName(),
  38. 'url' => $breadcrumb->isUrl() && $count != $number ? $breadcrumb->getUrl() : null,
  39. 'icon' => $breadcrumb->isIcon() ? $breadcrumb->getIcon() : null
  40. ];
  41. }
  42. }
  43. elseif ($action && $action !== 'index')
  44. {
  45. $this->data[] = [
  46. 'name' => $action,
  47. 'url' => $menu[$controller]['submenu'][$action]['url'],
  48. 'icon' => $menu[$controller]['submenu'][$action]['icon']
  49. ];
  50. }
  51. return $this;
  52. }
  53. /**
  54. * @return array
  55. */
  56. public function get()
  57. {
  58. return $this->data;
  59. }
  60. }