Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Parameter.php
Go to the documentation of this file.
1 <?php
33 {
37  protected $_defaultValue;
38 
42  protected $_description = '';
43 
47  protected $_name;
48 
52  protected $_optional = false;
53 
57  protected $_type = 'mixed';
58 
65  public function __construct($options = null)
66  {
67  if (is_array($options)) {
68  $this->setOptions($options);
69  }
70  }
71 
78  public function setOptions(array $options)
79  {
80  foreach ($options as $key => $value) {
81  $method = 'set' . ucfirst($key);
82  if (method_exists($this, $method)) {
83  $this->$method($value);
84  }
85  }
86  return $this;
87  }
88 
95  public function setDefaultValue($defaultValue)
96  {
97  $this->_defaultValue = $defaultValue;
98  return $this;
99  }
100 
106  public function getDefaultValue()
107  {
108  return $this->_defaultValue;
109  }
110 
117  public function setDescription($description)
118  {
119  $this->_description = (string) $description;
120  return $this;
121  }
122 
128  public function getDescription()
129  {
130  return $this->_description;
131  }
132 
139  public function setName($name)
140  {
141  $this->_name = (string) $name;
142  return $this;
143  }
144 
150  public function getName()
151  {
152  return $this->_name;
153  }
154 
161  public function setOptional($flag)
162  {
163  $this->_optional = (bool) $flag;
164  return $this;
165  }
166 
172  public function isOptional()
173  {
174  return $this->_optional;
175  }
176 
183  public function setType($type)
184  {
185  $this->_type = (string) $type;
186  return $this;
187  }
188 
194  public function getType()
195  {
196  return $this->_type;
197  }
198 
204  public function toArray()
205  {
206  return array(
207  'type' => $this->getType(),
208  'name' => $this->getName(),
209  'optional' => $this->isOptional(),
210  'defaultValue' => $this->getDefaultValue(),
211  'description' => $this->getDescription(),
212  );
213  }
214 }
setOptions(array $options)
Definition: Parameter.php:78
setDefaultValue($defaultValue)
Definition: Parameter.php:95
setDescription($description)
Definition: Parameter.php:117
$type
Definition: item.phtml:13
__construct($options=null)
Definition: Parameter.php:65
$value
Definition: gender.phtml:16
$method
Definition: info.phtml:13
if(!isset($_GET['name'])) $name
Definition: log.php:14