1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\SingleApp\Core\SimpleDeployment |
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/single-app |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\SingleApp\Core; |
22
|
|
|
|
23
|
|
|
use AppserverIo\Appserver\Core\GenericDeployment; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Deployment implementation for container's with a single app configuration. |
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/single-app |
32
|
|
|
* @link http://www.appserver.io |
33
|
|
|
*/ |
34
|
|
|
class SimpleDeployment extends GenericDeployment |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Returns the deployment service instance. |
39
|
|
|
* |
40
|
|
|
* @return \AppserverIo\Appserver\Core\Api\DeploymentService The deployment service instance |
41
|
|
|
*/ |
42
|
|
|
public function getDeploymentService() |
43
|
|
|
{ |
44
|
|
|
if ($this->deploymentService == null) { |
45
|
|
|
$this->deploymentService = $this->newService('AppserverIo\SingleApp\Core\Api\SimpleDeploymentService'); |
46
|
|
|
} |
47
|
|
|
return $this->deploymentService; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Return's the container's directory with applications to be deployed. |
52
|
|
|
* |
53
|
|
|
* @return string The container's application base directory |
54
|
|
|
*/ |
55
|
|
|
protected function getAppBase() |
56
|
|
|
{ |
57
|
|
|
return getcwd(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Load's and return's the context instances for the container. |
62
|
|
|
* |
63
|
|
|
* @return array The array with the container's context instances |
64
|
|
|
*/ |
65
|
|
|
protected function loadContextInstances() |
66
|
|
|
{ |
67
|
|
|
return $this->getDeploymentService()->loadContextInstancesByWorkingDir($this->getContainer()); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: