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
|
|
* Abstract class providing properties and methods common to all
|
22
|
|
* the project components
|
23
|
|
*
|
24
|
|
* @author Andreas Aderhold <andi@binarycloud.com>
|
25
|
|
* @author Hans Lellelid <hans@xmpl.org>
|
26
|
|
*
|
27
|
|
* @package phing
|
28
|
|
*/
|
29
|
|
abstract class ProjectComponent
|
30
|
|
{
|
31
|
|
/**
|
32
|
|
* Holds a reference to the project that a project component
|
33
|
|
* (a task, a target, etc.) belongs to
|
34
|
|
*
|
35
|
|
* @var Project $project A reference to the current project instance
|
36
|
|
*/
|
37
|
|
protected $project = null;
|
38
|
|
|
39
|
|
/**
|
40
|
|
* @var Location $location
|
41
|
|
*/
|
42
|
|
private $location;
|
43
|
|
|
44
|
|
/**
|
45
|
|
* @var string $description
|
46
|
|
*/
|
47
|
|
private $description;
|
48
|
|
|
49
|
1
|
public function __construct()
|
50
|
|
{
|
51
|
1
|
$this->location = new Location();
|
52
|
|
}
|
53
|
|
|
54
|
|
/**
|
55
|
|
* References the project to the current component.
|
56
|
|
*
|
57
|
|
* @param Project $project The reference to the current project
|
58
|
|
*
|
59
|
|
* @return void
|
60
|
|
*/
|
61
|
1
|
public function setProject($project)
|
62
|
|
{
|
63
|
1
|
$this->project = $project;
|
64
|
|
}
|
65
|
|
|
66
|
|
/**
|
67
|
|
* Returns a reference to current project
|
68
|
|
*
|
69
|
|
* @return Project Reference to current porject object
|
70
|
|
*/
|
71
|
1
|
public function getProject()
|
72
|
|
{
|
73
|
1
|
return $this->project;
|
74
|
|
}
|
75
|
|
|
76
|
|
/**
|
77
|
|
* Returns the file/location where this task was defined.
|
78
|
|
*
|
79
|
|
* @return Location the file/location where this task was defined.
|
80
|
|
* Should not return <code>null</code>.
|
81
|
|
*/
|
82
|
1
|
public function getLocation()
|
83
|
|
{
|
84
|
1
|
return $this->location;
|
85
|
|
}
|
86
|
|
|
87
|
|
/**
|
88
|
|
* Sets the file/location where this task was defined.
|
89
|
|
*
|
90
|
|
* @param Location $location The file/location where this task was defined.
|
91
|
|
* Should not be <code>null</code>
|
92
|
|
*/
|
93
|
1
|
public function setLocation(Location $location)
|
94
|
|
{
|
95
|
1
|
$this->location = $location;
|
96
|
|
}
|
97
|
|
|
98
|
|
/**
|
99
|
|
* Sets a description of the current action. This may be used for logging
|
100
|
|
* purposes.
|
101
|
|
*
|
102
|
|
* @param string $desc Description of the current action.
|
103
|
|
* May be <code>null</code>, indicating that no description is
|
104
|
|
* available.
|
105
|
|
*/
|
106
|
1
|
public function setDescription($desc)
|
107
|
|
{
|
108
|
1
|
$this->description = $desc;
|
109
|
|
}
|
110
|
|
|
111
|
|
/**
|
112
|
|
* Returns the description of the current action.
|
113
|
|
*
|
114
|
|
* @return string the description of the current action, or <code>null</code> if
|
115
|
|
* no description is available.
|
116
|
|
*/
|
117
|
1
|
public function getDescription()
|
118
|
|
{
|
119
|
1
|
return $this->description;
|
120
|
|
}
|
121
|
|
|
122
|
|
/**
|
123
|
|
* Logs a message with the given priority.
|
124
|
|
*
|
125
|
|
* @param string $msg The message to be logged.
|
126
|
|
* @param integer $level The message's priority at this message should have
|
127
|
|
*
|
128
|
|
* @return void
|
129
|
|
*/
|
130
|
1
|
public function log($msg, $level = Project::MSG_INFO)
|
131
|
|
{
|
132
|
1
|
if ($this->project !== null) {
|
133
|
1
|
$this->project->log($msg, $level);
|
134
|
|
}
|
135
|
|
}
|
136
|
|
}
|