1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
15
|
|
|
* |
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
17
|
|
|
* and is licensed under the LGPL. For more information please see |
18
|
|
|
* <http://phing.info>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace Phing\Dispatch; |
22
|
|
|
|
23
|
|
|
use Phing\Task; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Tasks extending this class may contain multiple actions. |
27
|
|
|
* The method that is invoked for execution depends upon the |
28
|
|
|
* value of the action attribute of the task. |
29
|
|
|
* <br> |
30
|
|
|
* Example:<br> |
31
|
|
|
* <mytask action="list"/> will invoke the method |
32
|
|
|
* with the signature public function list() in mytask's class. |
33
|
|
|
* If the action attribute is not defined in the task or is empty, |
34
|
|
|
* the main() method will be called. |
35
|
|
|
* |
36
|
|
|
* @author Siad Ardroumli <[email protected]> |
37
|
|
|
*/ |
38
|
|
|
abstract class DispatchTask extends Task implements Dispatchable |
39
|
|
|
{ |
40
|
|
|
private $action; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Get the action parameter name. |
44
|
|
|
* |
45
|
|
|
* @return string the <code>String</code> "action" by default (can be overridden) |
46
|
|
|
*/ |
47
|
|
|
public function getActionParameterName() |
48
|
|
|
{ |
49
|
|
|
return 'action'; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Set the action. |
54
|
|
|
* |
55
|
|
|
* @param string $action the method name |
56
|
|
|
*/ |
57
|
|
|
public function setAction($action) |
58
|
|
|
{ |
59
|
|
|
$this->action = $action; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get the action. |
64
|
|
|
* |
65
|
|
|
* @return string the action |
66
|
|
|
*/ |
67
|
|
|
public function getAction() |
68
|
|
|
{ |
69
|
|
|
return $this->action; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|