Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Definition.php
Go to the documentation of this file.
1 <?php
31 class Zend_Server_Definition implements Countable, Iterator
32 {
36  protected $_methods = array();
37 
41  protected $_overwriteExistingMethods = false;
42 
49  public function __construct($methods = null)
50  {
51  if (is_array($methods)) {
52  $this->setMethods($methods);
53  }
54  }
55 
62  public function setOverwriteExistingMethods($flag)
63  {
64  $this->_overwriteExistingMethods = (bool) $flag;
65  return $this;
66  }
67 
76  public function addMethod($method, $name = null)
77  {
78  if (is_array($method)) {
79  #require_once 'Zend/Server/Method/Definition.php';
82  #require_once 'Zend/Server/Exception.php';
83  throw new Zend_Server_Exception('Invalid method provided');
84  }
85 
86  if (is_numeric($name)) {
87  $name = null;
88  }
89  if (null !== $name) {
90  $method->setName($name);
91  } else {
92  $name = $method->getName();
93  }
94  if (null === $name) {
95  #require_once 'Zend/Server/Exception.php';
96  throw new Zend_Server_Exception('No method name provided');
97  }
98 
99  if (!$this->_overwriteExistingMethods && array_key_exists($name, $this->_methods)) {
100  #require_once 'Zend/Server/Exception.php';
101  throw new Zend_Server_Exception(sprintf('Method by name of "%s" already exists', $name));
102  }
103  $this->_methods[$name] = $method;
104  return $this;
105  }
106 
113  public function addMethods(array $methods)
114  {
115  foreach ($methods as $key => $method) {
116  $this->addMethod($method, $key);
117  }
118  return $this;
119  }
120 
127  public function setMethods(array $methods)
128  {
129  $this->clearMethods();
130  $this->addMethods($methods);
131  return $this;
132  }
133 
140  public function hasMethod($method)
141  {
142  return array_key_exists($method, $this->_methods);
143  }
144 
151  public function getMethod($method)
152  {
153  if ($this->hasMethod($method)) {
154  return $this->_methods[$method];
155  }
156  return false;
157  }
158 
164  public function getMethods()
165  {
166  return $this->_methods;
167  }
168 
175  public function removeMethod($method)
176  {
177  if ($this->hasMethod($method)) {
178  unset($this->_methods[$method]);
179  }
180  return $this;
181  }
182 
188  public function clearMethods()
189  {
190  $this->_methods = array();
191  return $this;
192  }
193 
199  public function toArray()
200  {
201  $methods = array();
202  foreach ($this->getMethods() as $key => $method) {
203  $methods[$key] = $method->toArray();
204  }
205  return $methods;
206  }
207 
213  public function count()
214  {
215  return count($this->_methods);
216  }
217 
223  public function current()
224  {
225  return current($this->_methods);
226  }
227 
233  public function key()
234  {
235  return key($this->_methods);
236  }
237 
243  public function next()
244  {
245  return next($this->_methods);
246  }
247 
253  public function rewind()
254  {
255  return reset($this->_methods);
256  }
257 
263  public function valid()
264  {
265  return (bool) $this->current();
266  }
267 }
addMethods(array $methods)
Definition: Definition.php:113
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
setOverwriteExistingMethods($flag)
Definition: Definition.php:62
$methods
Definition: billing.phtml:71
setMethods(array $methods)
Definition: Definition.php:127
addMethod($method, $name=null)
Definition: Definition.php:76
$method
Definition: info.phtml:13
__construct($methods=null)
Definition: Definition.php:49
if(!isset($_GET['name'])) $name
Definition: log.php:14