| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
require_once 'phing/system/lang/EventObject.php'; |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
class BuildEvent extends EventObject { |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
* A reference to the project |
|---|
| 47 |
* @var Project |
|---|
| 48 |
*/ |
|---|
| 49 |
protected $project; |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
* A reference to the target |
|---|
| 53 |
* @var Target |
|---|
| 54 |
*/ |
|---|
| 55 |
protected $target; |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
* A reference to the task |
|---|
| 59 |
* |
|---|
| 60 |
* @var Task |
|---|
| 61 |
*/ |
|---|
| 62 |
protected $task; |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
* The message of this event, if the event is a message |
|---|
| 66 |
* @var string |
|---|
| 67 |
*/ |
|---|
| 68 |
protected $message = null; |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
* The priority of the message |
|---|
| 72 |
* |
|---|
| 73 |
* @var string |
|---|
| 74 |
* @see $message |
|---|
| 75 |
*/ |
|---|
| 76 |
protected $priority = Project::MSG_VERBOSE; |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
* The execption that caused the event, if any |
|---|
| 80 |
* |
|---|
| 81 |
* @var object |
|---|
| 82 |
*/ |
|---|
| 83 |
protected $exception = null; |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
* Construct a BuildEvent for a project, task or target source event |
|---|
| 87 |
* |
|---|
| 88 |
* @param object project the project that emitted the event. |
|---|
| 89 |
*/ |
|---|
| 90 |
public function __construct($source) { |
|---|
| 91 |
parent::__construct($source); |
|---|
| 92 |
if ($source instanceof Project) { |
|---|
| 93 |
$this->project = $source; |
|---|
| 94 |
$this->target = null; |
|---|
| 95 |
$this->task = null; |
|---|
| 96 |
} elseif ($source instanceof Target) { |
|---|
| 97 |
$this->project = $source->getProject(); |
|---|
| 98 |
$this->target = $source; |
|---|
| 99 |
$this->task = null; |
|---|
| 100 |
} elseif ($source instanceof Task) { |
|---|
| 101 |
$this->project = $source->getProject(); |
|---|
| 102 |
$this->target = $source->getOwningTarget(); |
|---|
| 103 |
$this->task = $source; |
|---|
| 104 |
} else { |
|---|
| 105 |
throw new Exception("Can not construct BuildEvent, unknown source given."); |
|---|
| 106 |
} |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
* Sets the message with details and the message priority for this event. |
|---|
| 111 |
* |
|---|
| 112 |
* @param string The string message of the event |
|---|
| 113 |
* @param integer The priority this message should have |
|---|
| 114 |
*/ |
|---|
| 115 |
public function setMessage($message, $priority) { |
|---|
| 116 |
$this->message = (string) $message; |
|---|
| 117 |
$this->priority = (int) $priority; |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
* Set the exception that was the cause of this event. |
|---|
| 122 |
* |
|---|
| 123 |
* @param Exception The exception that caused the event |
|---|
| 124 |
*/ |
|---|
| 125 |
public function setException($exception) { |
|---|
| 126 |
$this->exception = $exception; |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
* Returns the project instance that fired this event. |
|---|
| 131 |
* |
|---|
| 132 |
* The reference to the project instance is set by the constructor if this |
|---|
| 133 |
* event was fired from the project class. |
|---|
| 134 |
* |
|---|
| 135 |
* @return Project The project instance that fired this event |
|---|
| 136 |
*/ |
|---|
| 137 |
public function getProject() { |
|---|
| 138 |
return $this->project; |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
* Returns the target instance that fired this event. |
|---|
| 143 |
* |
|---|
| 144 |
* The reference to the target instance is set by the constructor if this |
|---|
| 145 |
* event was fired from the target class. |
|---|
| 146 |
* |
|---|
| 147 |
* @return Target The target that fired this event |
|---|
| 148 |
*/ |
|---|
| 149 |
public function getTarget() { |
|---|
| 150 |
return $this->target; |
|---|
| 151 |
} |
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
* Returns the target instance that fired this event. |
|---|
| 155 |
* |
|---|
| 156 |
* The reference to the task instance is set by the constructor if this |
|---|
| 157 |
* event was fired within a task. |
|---|
| 158 |
* |
|---|
| 159 |
* @return Task The task that fired this event |
|---|
| 160 |
*/ |
|---|
| 161 |
public function getTask() { |
|---|
| 162 |
return $this->task; |
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
* Returns the logging message. This field will only be set for |
|---|
| 167 |
* "messageLogged" events. |
|---|
| 168 |
* |
|---|
| 169 |
* @return string The log message |
|---|
| 170 |
*/ |
|---|
| 171 |
function getMessage() { |
|---|
| 172 |
return $this->message; |
|---|
| 173 |
} |
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
* Returns the priority of the logging message. This field will only |
|---|
| 177 |
* be set for "messageLogged" events. |
|---|
| 178 |
* |
|---|
| 179 |
* @return integer The message priority |
|---|
| 180 |
*/ |
|---|
| 181 |
function getPriority() { |
|---|
| 182 |
return $this->priority; |
|---|
| 183 |
} |
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
* Returns the exception that was thrown, if any. |
|---|
| 187 |
* This field will only be set for "taskFinished", "targetFinished", and |
|---|
| 188 |
* "buildFinished" events. |
|---|
| 189 |
* |
|---|
| 190 |
* @see BuildListener::taskFinished() |
|---|
| 191 |
* @see BuildListener::targetFinished() |
|---|
| 192 |
* @see BuildListener::buildFinished() |
|---|
| 193 |
* @return Exception |
|---|
| 194 |
*/ |
|---|
| 195 |
public function getException() { |
|---|
| 196 |
return $this->exception; |
|---|
| 197 |
} |
|---|
| 198 |
} |
|---|
| 199 |
|
|---|