Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Widget.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Backend\Block;
7 
16 {
20  public function getId()
21  {
22  if (null === $this->getData('id')) {
23  $this->setData('id', $this->mathRandom->getUniqueHash('id_'));
24  }
25  return $this->getData('id');
26  }
27 
34  public function getSuffixId($suffix)
35  {
36  return "{$this->getId()}_{$suffix}";
37  }
38 
42  public function getHtmlId()
43  {
44  return $this->getId();
45  }
46 
53  public function getCurrentUrl($params = [])
54  {
55  if (!isset($params['_current'])) {
56  $params['_current'] = true;
57  }
58  return $this->getUrl('*/*/*', $params);
59  }
60 
67  protected function _addBreadcrumb($label, $title = null, $link = null)
68  {
69  $this->getLayout()->getBlock('breadcrumbs')->addLink($label, $title, $link);
70  }
71 
82  public function getButtonHtml($label, $onclick, $class = '', $buttonId = null, $dataAttr = [])
83  {
84  return $this->getLayout()->createBlock(
85  \Magento\Backend\Block\Widget\Button::class
86  )->setData(
87  ['label' => $label, 'onclick' => $onclick, 'class' => $class, 'type' => 'button', 'id' => $buttonId]
88  )->setDataAttribute(
89  $dataAttr
90  )->toHtml();
91  }
92 }
$title
Definition: default.phtml:14
getCurrentUrl($params=[])
Definition: Widget.php:53
$suffix
Definition: name.phtml:27
getData($key='', $index=null)
Definition: DataObject.php:119
getButtonHtml($label, $onclick, $class='', $buttonId=null, $dataAttr=[])
Definition: Widget.php:82
_addBreadcrumb($label, $title=null, $link=null)
Definition: Widget.php:67
$label
Definition: details.phtml:21
$_option $_optionId $class
Definition: date.phtml:13
setData($key, $value=null)
Definition: DataObject.php:72
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18