Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Breadcrumbs.php
Go to the documentation of this file.
1 <?php
10 namespace Magento\Catalog\Block;
11 
15 
17 {
23  protected $_catalogData = null;
24 
30  public function __construct(Context $context, Data $catalogData, array $data = [])
31  {
32  $this->_catalogData = $catalogData;
33  parent::__construct($context, $data);
34  }
35 
42  public function getTitleSeparator($store = null)
43  {
44  $separator = (string)$this->_scopeConfig->getValue(
45  'catalog/seo/title_separator',
47  $store
48  );
49  return ' ' . $separator . ' ';
50  }
51 
57  protected function _prepareLayout()
58  {
59  if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
60  $breadcrumbsBlock->addCrumb(
61  'home',
62  [
63  'label' => __('Home'),
64  'title' => __('Go to Home Page'),
65  'link' => $this->_storeManager->getStore()->getBaseUrl()
66  ]
67  );
68 
69  $title = [];
70  $path = $this->_catalogData->getBreadcrumbPath();
71 
72  foreach ($path as $name => $breadcrumb) {
73  $breadcrumbsBlock->addCrumb($name, $breadcrumb);
74  $title[] = $breadcrumb['label'];
75  }
76 
77  $this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($title)));
78  }
79  return parent::_prepareLayout();
80  }
81 }
$title
Definition: default.phtml:14
__()
Definition: __.php:13
__construct(Context $context, Data $catalogData, array $data=[])
Definition: Breadcrumbs.php:30
if(!isset($_GET['name'])) $name
Definition: log.php:14