You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Breadcrumb.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace SCF\Core;
  3. class Breadcrumb {
  4. /**
  5. * @var string
  6. */
  7. private $pageTitle;
  8. /**
  9. * @var string
  10. */
  11. private $subTitle;
  12. /**
  13. * @var array
  14. */
  15. private $breadcrumb = [];
  16. /**
  17. * @var array
  18. */
  19. private $pageHeader = [];
  20. /**
  21. * @param $pageTitle
  22. */
  23. public function setPageTitle($pageTitle)
  24. {
  25. $this->pageTitle = $pageTitle;
  26. }
  27. /**
  28. * @param string $subTitle
  29. */
  30. public function setSubTitle($subTitle)
  31. {
  32. $this->subTitle = $subTitle;
  33. }
  34. /**
  35. * @return string
  36. */
  37. public function getPageTitle()
  38. {
  39. return $this->pageTitle;
  40. }
  41. /**
  42. * @return string
  43. */
  44. public function getSubTitle()
  45. {
  46. return $this->subTitle;
  47. }
  48. /**
  49. * @param array $breadcrumb
  50. */
  51. public function setBreadcrumb($breadcrumb)
  52. {
  53. $this->generateBreadcrumb($breadcrumb);
  54. }
  55. /**
  56. * @param array $breadcrumb
  57. */
  58. private function generateBreadcrumb($breadcrumb)
  59. {
  60. foreach ($breadcrumb as $key=>$value) {
  61. $this->breadcrumb[$value] = $key;
  62. }
  63. }
  64. /**
  65. * @return array
  66. */
  67. public function getBreadcrumb()
  68. {
  69. return $this->breadcrumb;
  70. }
  71. /**
  72. * @param array $pageHeaderArray
  73. */
  74. public function setPageHeader(array $pageHeaderArray)
  75. {
  76. $this->pageHeader = $this->genPageHeader($pageHeaderArray);
  77. }
  78. /**
  79. * @return array
  80. */
  81. public function getPageHeader(): array
  82. {
  83. return $this->pageHeader;
  84. }
  85. /**
  86. * @param array $pageHeaderArray
  87. * @return array
  88. */
  89. private function genPageHeader(array $pageHeaderArray)
  90. {
  91. $temp = [
  92. 'pageTitle' => $pageHeaderArray[0],
  93. 'subTitle' => $pageHeaderArray[1]
  94. ];
  95. return $temp;
  96. }
  97. }