Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Prototype.php
Go to the documentation of this file.
1 <?php
33 {
37  protected $_returnType = 'void';
38 
42  protected $_parameterNameMap = array();
43 
47  protected $_parameters = array();
48 
55  public function __construct($options = null)
56  {
57  if ((null !== $options) && is_array($options)) {
58  $this->setOptions($options);
59  }
60  }
61 
68  public function setReturnType($returnType)
69  {
70  $this->_returnType = $returnType;
71  return $this;
72  }
73 
79  public function getReturnType()
80  {
81  return $this->_returnType;
82  }
83 
90  public function addParameter($parameter)
91  {
92  if ($parameter instanceof Zend_Server_Method_Parameter) {
93  $this->_parameters[] = $parameter;
94  if (null !== ($name = $parameter->getName())) {
95  $this->_parameterNameMap[$name] = count($this->_parameters) - 1;
96  }
97  } else {
98  #require_once 'Zend/Server/Method/Parameter.php';
99  $parameter = new Zend_Server_Method_Parameter(array(
100  'type' => (string) $parameter,
101  ));
102  $this->_parameters[] = $parameter;
103  }
104  return $this;
105  }
106 
113  public function addParameters(array $parameters)
114  {
115  foreach ($parameters as $parameter) {
116  $this->addParameter($parameter);
117  }
118  return $this;
119  }
120 
127  public function setParameters(array $parameters)
128  {
129  $this->_parameters = array();
130  $this->_parameterNameMap = array();
131  $this->addParameters($parameters);
132  return $this;
133  }
134 
140  public function getParameters()
141  {
142  $types = array();
143  foreach ($this->_parameters as $parameter) {
144  $types[] = $parameter->getType();
145  }
146  return $types;
147  }
148 
154  public function getParameterObjects()
155  {
156  return $this->_parameters;
157  }
158 
165  public function getParameter($index)
166  {
167  if (!is_string($index) && !is_numeric($index)) {
168  return null;
169  }
170  if (array_key_exists($index, $this->_parameterNameMap)) {
171  $index = $this->_parameterNameMap[$index];
172  }
173  if (array_key_exists($index, $this->_parameters)) {
174  return $this->_parameters[$index];
175  }
176  return null;
177  }
178 
185  public function setOptions(array $options)
186  {
187  foreach ($options as $key => $value) {
188  $method = 'set' . ucfirst($key);
189  if (method_exists($this, $method)) {
190  $this->$method($value);
191  }
192  }
193  return $this;
194  }
195 
201  public function toArray()
202  {
203  return array(
204  'returnType' => $this->getReturnType(),
205  'parameters' => $this->getParameters(),
206  );
207  }
208 }
$value
Definition: gender.phtml:16
addParameters(array $parameters)
Definition: Prototype.php:113
$method
Definition: info.phtml:13
setParameters(array $parameters)
Definition: Prototype.php:127
$index
Definition: list.phtml:44
setOptions(array $options)
Definition: Prototype.php:185
__construct($options=null)
Definition: Prototype.php:55
if(!isset($_GET['name'])) $name
Definition: log.php:14