Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Server_Method_Callback Class Reference

Public Member Functions

 __construct ($options=null)
 
 setOptions (array $options)
 
 setClass ($class)
 
 getClass ()
 
 setFunction ($function)
 
 getFunction ()
 
 setMethod ($method)
 
 getMethod ()
 
 setType ($type)
 
 getType ()
 
 toArray ()
 

Protected Attributes

 $_class
 
 $_function
 
 $_method
 
 $_type
 
 $_types = array('function', 'static', 'instance')
 

Detailed Description

Definition at line 32 of file Callback.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = null)

Constructor

Parameters
null | array$options
Returns
void

Definition at line 65 of file Callback.php.

66  {
67  if ((null !== $options) && is_array($options)) {
68  $this->setOptions($options);
69  }
70  }
setOptions(array $options)
Definition: Callback.php:78

Member Function Documentation

◆ getClass()

getClass ( )

Get callback class

Returns
string|null

Definition at line 109 of file Callback.php.

110  {
111  return $this->_class;
112  }

◆ getFunction()

getFunction ( )

Get callback function

Returns
null|string

Definition at line 132 of file Callback.php.

133  {
134  return $this->_function;
135  }

◆ getMethod()

getMethod ( )

Get callback class method

Returns
null|string

Definition at line 154 of file Callback.php.

155  {
156  return $this->_method;
157  }

◆ getType()

getType ( )

Get callback type

Returns
string

Definition at line 181 of file Callback.php.

182  {
183  return $this->_type;
184  }

◆ setClass()

setClass (   $class)

Set callback class

Parameters
string$class
Returns
Zend_Server_Method_Callback

Definition at line 95 of file Callback.php.

96  {
97  if (is_object($class)) {
98  $class = get_class($class);
99  }
100  $this->_class = $class;
101  return $this;
102  }
$_option $_optionId $class
Definition: date.phtml:13

◆ setFunction()

setFunction (   $function)

Set callback function

Parameters
string$function
Returns
Zend_Server_Method_Callback

Definition at line 120 of file Callback.php.

121  {
122  $this->_function = (string) $function;
123  $this->setType('function');
124  return $this;
125  }

◆ setMethod()

setMethod (   $method)

Set callback class method

Parameters
string$method
Returns
Zend_Server_Method_Callback

Definition at line 143 of file Callback.php.

144  {
145  $this->_method = $method;
146  return $this;
147  }
$method
Definition: info.phtml:13

◆ setOptions()

setOptions ( array  $options)

Set object state from array of options

Parameters
array$options
Returns
Zend_Server_Method_Callback

Definition at line 78 of file Callback.php.

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  }
$value
Definition: gender.phtml:16
$method
Definition: info.phtml:13

◆ setType()

setType (   $type)

Set callback type

Parameters
string$type
Returns
Zend_Server_Method_Callback
Exceptions
Zend_Server_Exception

Definition at line 166 of file Callback.php.

167  {
168  if (!in_array($type, $this->_types)) {
169  #require_once 'Zend/Server/Exception.php';
170  throw new Zend_Server_Exception('Invalid method callback type passed to ' . __CLASS__ . '::' . __METHOD__);
171  }
172  $this->_type = $type;
173  return $this;
174  }
$type
Definition: item.phtml:13

◆ toArray()

toArray ( )

Cast callback to array

Returns
array

Definition at line 191 of file Callback.php.

192  {
193  $type = $this->getType();
194  $array = array(
195  'type' => $type,
196  );
197  if ('function' == $type) {
198  $array['function'] = $this->getFunction();
199  } else {
200  $array['class'] = $this->getClass();
201  $array['method'] = $this->getMethod();
202  }
203  return $array;
204  }
$type
Definition: item.phtml:13

Field Documentation

◆ $_class

$_class
protected

Definition at line 37 of file Callback.php.

◆ $_function

$_function
protected

Definition at line 42 of file Callback.php.

◆ $_method

$_method
protected

Definition at line 47 of file Callback.php.

◆ $_type

$_type
protected

Definition at line 52 of file Callback.php.

◆ $_types

$_types = array('function', 'static', 'instance')
protected

Definition at line 57 of file Callback.php.


The documentation for this class was generated from the following file: