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