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
|
|
* Register a datatype for use within a buildfile.
|
22
|
|
*
|
23
|
|
* This is for registering your own datatypes for use within a buildfile.
|
24
|
|
*
|
25
|
|
* If you find that you are using a particular class frequently, you may want to edit the
|
26
|
|
* phing/types/defaults.properties file so that it is included by default. You may also
|
27
|
|
* want to submit it (if LGPL or compatible license) to be included in Phing distribution.
|
28
|
|
*
|
29
|
|
* <pre>
|
30
|
|
* <typedef name="mytype" classname="path.to.MyHandlingClass"/>
|
31
|
|
* .
|
32
|
|
* <sometask ...>
|
33
|
|
* <mytype param1="val1" param2="val2"/>
|
34
|
|
* </sometask>
|
35
|
|
* </pre>
|
36
|
|
*
|
37
|
|
* TODO:
|
38
|
|
* -- possibly refactor since this is almost the same as TaskDefTask
|
39
|
|
* (right now these are just too simple to really justify creating an abstract class)
|
40
|
|
*
|
41
|
|
* @author Hans Lellelid <hans@xmpl.org>
|
42
|
|
* @package phing.tasks.system
|
43
|
|
*/
|
44
|
|
class TypedefTask extends Task
|
45
|
|
{
|
46
|
|
use ClasspathAware;
|
47
|
|
|
48
|
|
/**
|
49
|
|
* Tag name for datatype that will be used in XML
|
50
|
|
*/
|
51
|
|
private $name;
|
52
|
|
|
53
|
|
/**
|
54
|
|
* Classname of task to register.
|
55
|
|
* This can be a dot-path -- relative to a location on PHP include_path.
|
56
|
|
* E.g. path.to.MyClass -> path/to/MyClass.php
|
57
|
|
*
|
58
|
|
* @var string
|
59
|
|
*/
|
60
|
|
private $classname;
|
61
|
|
|
62
|
|
/**
|
63
|
|
* Main entry point
|
64
|
|
*/
|
65
|
1
|
public function main()
|
66
|
|
{
|
67
|
1
|
if ($this->name === null || $this->classname === null) {
|
68
|
1
|
throw new BuildException("You must specify name and class attributes for <typedef>.");
|
69
|
|
}
|
70
|
1
|
$this->project->addDataTypeDefinition($this->name, $this->classname, $this->classpath);
|
71
|
|
}
|
72
|
|
|
73
|
|
/**
|
74
|
|
* Sets the name that will be used in XML buildfile.
|
75
|
|
*
|
76
|
|
* @param string $name
|
77
|
|
*/
|
78
|
1
|
public function setName($name)
|
79
|
|
{
|
80
|
1
|
$this->name = $name;
|
81
|
|
}
|
82
|
|
|
83
|
|
/**
|
84
|
|
* Sets the class name / dotpath to use.
|
85
|
|
*
|
86
|
|
* @param string $class
|
87
|
|
*/
|
88
|
1
|
public function setClassname($class)
|
89
|
|
{
|
90
|
1
|
$this->classname = $class;
|
91
|
|
}
|
92
|
|
}
|