Breadcrumbs.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block\Widget;
  7. /**
  8. * Magento_Backend page breadcrumbs
  9. *
  10. * @api
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. * @since 100.0.2
  13. */
  14. class Breadcrumbs extends \Magento\Backend\Block\Template
  15. {
  16. /**
  17. * Breadcrumbs links
  18. *
  19. * @var array
  20. */
  21. protected $_links = [];
  22. /**
  23. * @var string
  24. */
  25. protected $_template = 'Magento_Backend::widget/breadcrumbs.phtml';
  26. /**
  27. * @return void
  28. */
  29. protected function _construct()
  30. {
  31. $this->addLink(__('Home'), __('Home'), $this->getUrl('*'));
  32. }
  33. /**
  34. * @param string $label
  35. * @param string|null $title
  36. * @param string|null $url
  37. * @return $this
  38. */
  39. public function addLink($label, $title = null, $url = null)
  40. {
  41. if (empty($title)) {
  42. $title = $label;
  43. }
  44. $this->_links[] = ['label' => $label, 'title' => $title, 'url' => $url];
  45. return $this;
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. protected function _beforeToHtml()
  51. {
  52. // TODO - Moved to Beta 2, no breadcrumbs displaying in Beta 1
  53. // $this->assign('links', $this->_links);
  54. return parent::_beforeToHtml();
  55. }
  56. }