Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Attribute.php
Go to the documentation of this file.
1 <?php
15 namespace Magento\Eav\Model;
16 
18 
23 class Attribute extends \Magento\Eav\Model\Entity\Attribute
24 {
29  //const MODULE_NAME = 'Magento_Eav';
30 
35  protected $_eventObject = 'attribute';
36 
42  protected $_website;
43 
51  public function setWebsite($website)
52  {
53  $this->_website = $this->_storeManager->getWebsite($website);
54  return $this;
55  }
56 
62  public function getWebsite()
63  {
64  if ($this->_website === null) {
65  $this->_website = $this->_storeManager->getWebsite();
66  }
67 
68  return $this->_website;
69  }
70 
76  public function afterSave()
77  {
78  $this->_eavConfig->clear();
79  return parent::afterSave();
80  }
81 
87  public function getUsedInForms()
88  {
89  $forms = $this->getData('used_in_forms');
90  if ($forms === null) {
91  $forms = $this->_getResource()->getUsedInForms($this);
92  $this->setData('used_in_forms', $forms);
93  }
94  return $forms;
95  }
96 
102  public function getValidateRules()
103  {
104  $rules = $this->getData('validate_rules');
105  if (is_array($rules)) {
106  return $rules;
107  } elseif (!empty($rules)) {
108  return (array)$this->getSerializer()->unserialize($rules);
109  }
110  return [];
111  }
112 
119  public function setValidateRules($rules)
120  {
121  if (empty($rules)) {
122  $rules = null;
123  } elseif (is_array($rules)) {
124  $rules = $this->getSerializer()->serialize($rules);
125  }
126  $this->setData('validate_rules', $rules);
127 
128  return $this;
129  }
130 
137  protected function _getScopeValue($key)
138  {
139  $scopeKey = sprintf('scope_%s', $key);
140  if ($this->getData($scopeKey) !== null) {
141  return $this->getData($scopeKey);
142  }
143  return $this->getData($key);
144  }
145 
152  public function getIsRequired()
153  {
154  return $this->_getScopeValue('is_required');
155  }
156 
163  public function getIsVisible()
164  {
165  return $this->_getScopeValue('is_visible');
166  }
167 
174  public function getDefaultValue()
175  {
176  return $this->_getScopeValue('default_value');
177  }
178 
185  public function getMultilineCount()
186  {
187  return $this->_getScopeValue('multiline_count');
188  }
189 
193  public function afterDelete()
194  {
195  $this->_eavConfig->clear();
196  return parent::afterDelete();
197  }
198 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17