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
|
|
|
use Phing\Exception\BuildException; |
21
|
|
|
use Phing\Task; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @author Max Romanovsky <[email protected]> |
25
|
|
|
* @package phing.tasks.ext |
26
|
|
|
*/ |
27
|
|
|
class AutoloaderTask extends Task |
28
|
|
|
{ |
29
|
|
|
public const DEFAULT_AUTOLOAD_PATH = 'vendor/autoload.php'; |
30
|
|
|
|
31
|
|
|
private $autoloaderPath = self::DEFAULT_AUTOLOAD_PATH; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @return string |
35
|
|
|
*/ |
36
|
|
|
public function getAutoloaderPath() |
37
|
|
|
{ |
38
|
|
|
return $this->autoloaderPath; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param string $autoloaderPath |
43
|
|
|
*/ |
44
|
1 |
|
public function setAutoloaderPath($autoloaderPath) |
45
|
|
|
{ |
46
|
1 |
|
$this->autoloaderPath = $autoloaderPath; |
47
|
1 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Called by the project to let the task do it's work. This method may be |
51
|
|
|
* called more than once, if the task is invoked more than once. For |
52
|
|
|
* example, if target1 and target2 both depend on target3, then running |
53
|
|
|
* <em>phing target1 target2</em> will run all tasks in target3 twice. |
54
|
|
|
* |
55
|
|
|
* Should throw a BuildException if someting goes wrong with the build |
56
|
|
|
* |
57
|
|
|
* This is here. Must be overloaded by real tasks. |
58
|
|
|
*/ |
59
|
2 |
|
public function main() |
60
|
|
|
{ |
61
|
2 |
|
if (is_dir($this->autoloaderPath) || !is_readable($this->autoloaderPath)) { |
62
|
1 |
|
throw new BuildException( |
63
|
1 |
|
sprintf( |
64
|
1 |
|
'Provided autoloader file "%s" is not a readable file', |
65
|
1 |
|
$this->autoloaderPath |
66
|
|
|
) |
67
|
|
|
); |
68
|
|
|
} |
69
|
1 |
|
$this->log('Loading autoloader from ' . $this->autoloaderPath); |
70
|
1 |
|
include_once $this->autoloaderPath; |
71
|
1 |
|
} |
72
|
|
|
} |
73
|
|
|
|