Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Breadcrumbs Class Reference
Inheritance diagram for Breadcrumbs:
DataObject ArgumentInterface

Public Member Functions

 __construct (Data $catalogData, ScopeConfigInterface $scopeConfig, Json $json=null, Escaper $escaper=null)
 
 getCategoryUrlSuffix ()
 
 isCategoryUsedInProductUrl ()
 
 getProductName ()
 
 getJsonConfigurationHtmlEscaped ()
 
 getJsonConfiguration ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Additional Inherited Members

- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 
- Protected Attributes inherited from DataObject
 $_data = []
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Product breadcrumbs view model.

Definition at line 20 of file Breadcrumbs.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Data  $catalogData,
ScopeConfigInterface  $scopeConfig,
Json  $json = null,
Escaper  $escaper = null 
)
Parameters
Data$catalogData
ScopeConfigInterface$scopeConfig
Json | null$json
Escaper | null$escaper@SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 46 of file Breadcrumbs.php.

51  {
52  parent::__construct();
53 
54  $this->catalogData = $catalogData;
55  $this->scopeConfig = $scopeConfig;
56  $this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class);
57  }

Member Function Documentation

◆ getCategoryUrlSuffix()

getCategoryUrlSuffix ( )

Returns category URL suffix.

Returns
mixed

Definition at line 64 of file Breadcrumbs.php.

65  {
66  return $this->scopeConfig->getValue(
67  'catalog/seo/category_url_suffix',
68  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
69  );
70  }

◆ getJsonConfiguration()

getJsonConfiguration ( )

Returns breadcrumb json.

Returns
string
Deprecated:
in favor of new method with name {suffix}Html{postfix}()

Definition at line 122 of file Breadcrumbs.php.

123  {
124  return $this->getJsonConfigurationHtmlEscaped();
125  }

◆ getJsonConfigurationHtmlEscaped()

getJsonConfigurationHtmlEscaped ( )

Returns breadcrumb json with html escaped names

Returns
string

Definition at line 102 of file Breadcrumbs.php.

102  : string
103  {
104  return json_encode(
105  [
106  'breadcrumbs' => [
107  'categoryUrlSuffix' => $this->escaper->escapeHtml($this->getCategoryUrlSuffix()),
108  'userCategoryPathInUrl' => (int)$this->isCategoryUsedInProductUrl(),
109  'product' => $this->escaper->escapeHtml($this->getProductName())
110  ]
111  ],
112  JSON_HEX_TAG
113  );
114  }

◆ getProductName()

getProductName ( )

Returns product name.

Returns
string

Definition at line 90 of file Breadcrumbs.php.

90  : string
91  {
92  return $this->catalogData->getProduct() !== null
93  ? $this->catalogData->getProduct()->getName()
94  : '';
95  }

◆ isCategoryUsedInProductUrl()

isCategoryUsedInProductUrl ( )

Checks if categories path is used for product URLs.

Returns
bool

Definition at line 77 of file Breadcrumbs.php.

77  : bool
78  {
79  return $this->scopeConfig->isSetFlag(
80  'catalog/seo/product_use_categories',
81  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
82  );
83  }

The documentation for this class was generated from the following file: