1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* \AppserverIo\Appserver\DependencyInjectionContainer\AbstractParser |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io/appserver |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Appserver\DependencyInjectionContainer; |
22
|
|
|
|
23
|
|
|
use AppserverIo\Appserver\Core\Utilities\AppEnvironmentHelper; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Abstract deployment descriptor parser implementation. |
27
|
|
|
* |
28
|
|
|
* @author Tim Wagner <[email protected]> |
29
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
31
|
|
|
* @link https://github.com/appserver-io/appserver |
32
|
|
|
* @link http://www.appserver.io |
33
|
|
|
*/ |
34
|
|
|
abstract class AbstractDeploymentDescriptorParser extends AbstractParser |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Loads the environment aware deployment descriptors for the given manager. |
39
|
|
|
* |
40
|
|
|
* @return string[] The array with the deployment descriptors |
41
|
|
|
*/ |
42
|
|
|
protected function loadDeploymentDescriptors() |
43
|
|
|
{ |
44
|
|
|
|
45
|
|
|
// load the web application base directory |
46
|
|
|
$webappPath = $this->getApplication()->getWebappPath(); |
47
|
|
|
|
48
|
|
|
// load the deployment service |
49
|
|
|
/** @var \AppserverIo\Appserver\Core\Api\DeploymentService $deploymentService */ |
50
|
|
|
$deploymentService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\DeploymentService'); |
|
|
|
|
51
|
|
|
|
52
|
|
|
// prepare the array with the deployment descriptor with the fallback deployment descriptor |
53
|
|
|
$deploymentDescriptors = array($deploymentService->getConfdDir(sprintf('%s.xml', $descriptorName = $this->getConfiguration()->getDescriptorName()))); |
54
|
|
|
|
55
|
|
|
// try to locate deployment descriptors in the configured directories |
56
|
|
|
foreach ($this->getDirectories() as $directory) { |
57
|
|
|
// make sure we've a path, relative to the webapp directory |
58
|
|
|
$strippedDirectory = ltrim(str_replace($webappPath, '', $directory), DIRECTORY_SEPARATOR); |
59
|
|
|
|
60
|
|
|
// add the environment aware deployment descriptor to the array |
61
|
|
|
array_push( |
62
|
|
|
$deploymentDescriptors, |
63
|
|
|
AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, $strippedDirectory . DIRECTORY_SEPARATOR . $descriptorName) |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
// return the loaded deployment descriptors |
69
|
|
|
return $deploymentDescriptors; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|