| 1 |
lars |
1 |
<?php
|
|
|
2 |
/*
|
|
|
3 |
* $Id: TaskAdapter.php 144 2007-02-05 15:19:00Z hans $
|
|
|
4 |
*
|
|
|
5 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
6 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
7 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
8 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
9 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
10 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
11 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
12 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
13 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
14 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
15 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
16 |
*
|
|
|
17 |
* This software consists of voluntary contributions made by many individuals
|
|
|
18 |
* and is licensed under the LGPL. For more information please see
|
|
|
19 |
* <http://phing.info>.
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
require_once 'phing/Task.php';
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* Use introspection to "adapt" an arbitrary ( not extending Task, but with
|
|
|
26 |
* similar patterns).
|
|
|
27 |
*
|
|
|
28 |
* @author Andreas Aderhold <andi@binarycloud.com>
|
|
|
29 |
* @copyright © 2001,2002 THYRELL. All rights reserved
|
|
|
30 |
* @version $Revision: 1.7 $
|
|
|
31 |
* @package phing
|
|
|
32 |
*/
|
|
|
33 |
class TaskAdapter extends Task {
|
|
|
34 |
|
|
|
35 |
/** target object */
|
|
|
36 |
private $proxy;
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Main entry point.
|
|
|
40 |
* @return void
|
|
|
41 |
*/
|
|
|
42 |
function main() {
|
|
|
43 |
|
|
|
44 |
if (method_exists($this->proxy, "setProject")) {
|
|
|
45 |
try { // try to set project
|
|
|
46 |
$this->proxy->setProject($this->project);
|
|
|
47 |
} catch (Exception $ex) {
|
|
|
48 |
$this->log("Error setting project in " . get_class($this->proxy) . Project::MSG_ERR);
|
|
|
49 |
throw new BuildException($ex);
|
|
|
50 |
}
|
|
|
51 |
} else {
|
|
|
52 |
throw new Exception("Error setting project in class " . get_class($this->proxy));
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
if (method_exists($this->proxy, "main")) {
|
|
|
56 |
try { //try to call main
|
|
|
57 |
$this->proxy->main($this->project);
|
|
|
58 |
} catch (Exception $ex) {
|
|
|
59 |
$this->log("Error in " . get_class($this->proxy), Project::MSG_ERR);
|
|
|
60 |
throw new BuildException($ex->getMessage());
|
|
|
61 |
}
|
|
|
62 |
} else {
|
|
|
63 |
throw new BuildException("Your task-like class '" . get_class($this->proxy) ."' does not have a main() method");
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* Set the target object.
|
|
|
69 |
* @param object $o
|
|
|
70 |
* @return void
|
|
|
71 |
*/
|
|
|
72 |
function setProxy($o) {
|
|
|
73 |
$this->proxy = $o;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
/**
|
|
|
77 |
* Gets the target object.
|
|
|
78 |
* @return object
|
|
|
79 |
*/
|
|
|
80 |
function getProxy() {
|
|
|
81 |
return $this->proxy;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
}
|