| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
class sfPhingListener implements BuildListener |
|---|
| 4 |
{ |
|---|
| 5 |
static protected |
|---|
| 6 |
$exceptions = array(), |
|---|
| 7 |
$errors = array(); |
|---|
| 8 |
|
|---|
| 9 |
static public function hasErrors() |
|---|
| 10 |
{ |
|---|
| 11 |
return count(self::$errors) || count(self::$exceptions); |
|---|
| 12 |
} |
|---|
| 13 |
|
|---|
| 14 |
static public function getErrors() |
|---|
| 15 |
{ |
|---|
| 16 |
return self::$errors; |
|---|
| 17 |
} |
|---|
| 18 |
|
|---|
| 19 |
static public function getExceptions() |
|---|
| 20 |
{ |
|---|
| 21 |
return self::$exceptions; |
|---|
| 22 |
} |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
* Fired before any targets are started. |
|---|
| 26 |
* |
|---|
| 27 |
* @param BuildEvent The BuildEvent |
|---|
| 28 |
*/ |
|---|
| 29 |
public function buildStarted(BuildEvent $event) |
|---|
| 30 |
{ |
|---|
| 31 |
self::$exceptions = array(); |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
* Fired after the last target has finished. |
|---|
| 36 |
* |
|---|
| 37 |
* @param BuildEvent The BuildEvent |
|---|
| 38 |
* @see BuildEvent::getException() |
|---|
| 39 |
*/ |
|---|
| 40 |
public function buildFinished(BuildEvent $event) |
|---|
| 41 |
{ |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
* Fired when a target is started. |
|---|
| 46 |
* |
|---|
| 47 |
* @param BuildEvent The BuildEvent |
|---|
| 48 |
* @see BuildEvent::getTarget() |
|---|
| 49 |
*/ |
|---|
| 50 |
public function targetStarted(BuildEvent $event) |
|---|
| 51 |
{ |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
* Fired when a target has finished. |
|---|
| 56 |
* |
|---|
| 57 |
* @param BuildEvent The BuildEvent |
|---|
| 58 |
* @see BuildEvent#getException() |
|---|
| 59 |
*/ |
|---|
| 60 |
public function targetFinished(BuildEvent $event) |
|---|
| 61 |
{ |
|---|
| 62 |
if (!is_null($event->getException())) |
|---|
| 63 |
{ |
|---|
| 64 |
self::$exceptions[] = $event->getException(); |
|---|
| 65 |
} |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
* Fired when a task is started. |
|---|
| 70 |
* |
|---|
| 71 |
* @param BuildEvent The BuildEvent |
|---|
| 72 |
* @see BuildEvent::getTask() |
|---|
| 73 |
*/ |
|---|
| 74 |
public function taskStarted(BuildEvent $event) |
|---|
| 75 |
{ |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
* Fired when a task has finished. |
|---|
| 80 |
* |
|---|
| 81 |
* @param BuildEvent The BuildEvent |
|---|
| 82 |
* @see BuildEvent::getException() |
|---|
| 83 |
*/ |
|---|
| 84 |
public function taskFinished(BuildEvent $event) |
|---|
| 85 |
{ |
|---|
| 86 |
} |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
* Fired whenever a message is logged. |
|---|
| 90 |
* |
|---|
| 91 |
* @param BuildEvent The BuildEvent |
|---|
| 92 |
* @see BuildEvent::getMessage() |
|---|
| 93 |
*/ |
|---|
| 94 |
public function messageLogged(BuildEvent $event) |
|---|
| 95 |
{ |
|---|
| 96 |
if ($event->getPriority() == Project::MSG_ERR) |
|---|
| 97 |
{ |
|---|
| 98 |
if (preg_match('/XLST transformation/', $event->getMessage())) |
|---|
| 99 |
{ |
|---|
| 100 |
|
|---|
| 101 |
return; |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
$msg = ''; |
|---|
| 105 |
if ($event->getTask() !== null) |
|---|
| 106 |
{ |
|---|
| 107 |
$msg = sprintf('[%s] ', $event->getTask()->getTaskName()); |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
$msg .= $event->getMessage(); |
|---|
| 111 |
|
|---|
| 112 |
self::$errors[] = $msg; |
|---|
| 113 |
} |
|---|
| 114 |
} |
|---|
| 115 |
} |
|---|
| 116 |
|
|---|