| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class sfEvent implements ArrayAccess |
|---|
| 20 |
{ |
|---|
| 21 |
protected |
|---|
| 22 |
$value = null, |
|---|
| 23 |
$processed = false, |
|---|
| 24 |
$subject = null, |
|---|
| 25 |
$name = '', |
|---|
| 26 |
$parameters = null; |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
* Constructs a new sfEvent. |
|---|
| 30 |
* |
|---|
| 31 |
* @param mixed $subject The subject |
|---|
| 32 |
* @param string $name The event name |
|---|
| 33 |
* @param array $parameters An array of parameters |
|---|
| 34 |
*/ |
|---|
| 35 |
public function __construct($subject, $name, $parameters = array()) |
|---|
| 36 |
{ |
|---|
| 37 |
$this->subject = $subject; |
|---|
| 38 |
$this->name = $name; |
|---|
| 39 |
|
|---|
| 40 |
$this->parameters = $parameters; |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
* Returns the subject. |
|---|
| 45 |
* |
|---|
| 46 |
* @return mixed The subject |
|---|
| 47 |
*/ |
|---|
| 48 |
public function getSubject() |
|---|
| 49 |
{ |
|---|
| 50 |
return $this->subject; |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
* Returns the event name. |
|---|
| 55 |
* |
|---|
| 56 |
* @return string The event name |
|---|
| 57 |
*/ |
|---|
| 58 |
public function getName() |
|---|
| 59 |
{ |
|---|
| 60 |
return $this->name; |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
* Sets the return value for this event. |
|---|
| 65 |
* |
|---|
| 66 |
* @param mixed $value The return value |
|---|
| 67 |
*/ |
|---|
| 68 |
public function setReturnValue($value) |
|---|
| 69 |
{ |
|---|
| 70 |
$this->value = $value; |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
* Returns the return value. |
|---|
| 75 |
* |
|---|
| 76 |
* @return mixed The return value |
|---|
| 77 |
*/ |
|---|
| 78 |
public function getReturnValue() |
|---|
| 79 |
{ |
|---|
| 80 |
return $this->value; |
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
* Sets the processed flag. |
|---|
| 85 |
* |
|---|
| 86 |
* @param Boolean $processed The processed flag value |
|---|
| 87 |
*/ |
|---|
| 88 |
public function setProcessed($processed) |
|---|
| 89 |
{ |
|---|
| 90 |
$this->processed = (boolean) $processed; |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
* Returns whether the event has been processed by a listener or not. |
|---|
| 95 |
* |
|---|
| 96 |
* @return Boolean true if the event has been processed, false otherwise |
|---|
| 97 |
*/ |
|---|
| 98 |
public function isProcessed() |
|---|
| 99 |
{ |
|---|
| 100 |
return $this->processed; |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
* Returns the event parameters. |
|---|
| 105 |
* |
|---|
| 106 |
* @return array The event parameters |
|---|
| 107 |
*/ |
|---|
| 108 |
public function getParameters() |
|---|
| 109 |
{ |
|---|
| 110 |
return $this->parameters; |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
* Returns true if the parameter exists (implements the ArrayAccess interface). |
|---|
| 115 |
* |
|---|
| 116 |
* @param string $name The parameter name |
|---|
| 117 |
* |
|---|
| 118 |
* @return Boolean true if the parameter exists, false otherwise |
|---|
| 119 |
*/ |
|---|
| 120 |
public function offsetExists($name) |
|---|
| 121 |
{ |
|---|
| 122 |
return array_key_exists($name, $this->parameters); |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
* Returns a parameter value (implements the ArrayAccess interface). |
|---|
| 127 |
* |
|---|
| 128 |
* @param string $name The parameter name |
|---|
| 129 |
* |
|---|
| 130 |
* @return mixed The parameter value |
|---|
| 131 |
*/ |
|---|
| 132 |
public function offsetGet($name) |
|---|
| 133 |
{ |
|---|
| 134 |
if (!array_key_exists($name, $this->parameters)) |
|---|
| 135 |
{ |
|---|
| 136 |
throw new InvalidArgumentException(sprintf('The event "%s" has no "%s" parameter.', $this->name, $name)); |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
return $this->parameters[$name]; |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
* Sets a parameter (implements the ArrayAccess interface). |
|---|
| 144 |
* |
|---|
| 145 |
* @param string $name The parameter name |
|---|
| 146 |
* @param mixed $value The parameter value |
|---|
| 147 |
*/ |
|---|
| 148 |
public function offsetSet($name, $value) |
|---|
| 149 |
{ |
|---|
| 150 |
$this->parameters[$name] = $value; |
|---|
| 151 |
} |
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
* Removes a parameter (implements the ArrayAccess interface). |
|---|
| 155 |
* |
|---|
| 156 |
* @param string $name The parameter name |
|---|
| 157 |
*/ |
|---|
| 158 |
public function offsetUnset($name) |
|---|
| 159 |
{ |
|---|
| 160 |
unset($this->parameters[$name]); |
|---|
| 161 |
} |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|