appserver-io /
provisioning
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * AppserverIo\Provisioning\AbstractProvisioner |
||
| 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 2018 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/provisioning |
||
| 18 | * @link http://www.appserver.io |
||
| 19 | */ |
||
| 20 | |||
| 21 | namespace AppserverIo\Provisioning; |
||
| 22 | |||
| 23 | use AppserverIo\Psr\Application\ProvisionerInterface; |
||
| 24 | use AppserverIo\Psr\ApplicationServer\ContextInterface; |
||
| 25 | use AppserverIo\Provisioning\Configuration\ProvisionerConfigurationInterface; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Abstract base class that provides basic provisioning functionality. |
||
| 29 | * |
||
| 30 | * @author Tim Wagner <[email protected]> |
||
| 31 | * @copyright 2018 TechDivision GmbH <[email protected]> |
||
| 32 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
||
| 33 | * @link https://github.com/appserver-io/provisioning |
||
| 34 | * @link http://www.appserver.io |
||
| 35 | */ |
||
| 36 | abstract class AbstractProvisioner implements ProvisionerInterface |
||
| 37 | { |
||
| 38 | |||
| 39 | /** |
||
| 40 | * The initial context instance. |
||
| 41 | * |
||
| 42 | * @var \AppserverIo\Psr\ApplicationServer\ContextInterface |
||
| 43 | */ |
||
| 44 | protected $initialContext; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * The provisioning service instance. |
||
| 48 | * |
||
| 49 | * @var \AppserverIo\Psr\ApplicationServer\ServiceInterface |
||
| 50 | */ |
||
| 51 | protected $service; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * The provisioner node configuration data. |
||
| 55 | * |
||
| 56 | * @var \AppserverIo\Provisioning\Configuration\ProvisionerConfigurationInterface |
||
| 57 | */ |
||
| 58 | protected $provisionerNode; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Contructor to initialize the provisioner instance with the initial context |
||
| 62 | * and the provision node configuration data. |
||
| 63 | * |
||
| 64 | * @param \AppserverIo\Psr\ApplicationServer\ContextInterface $initialContext The initial context instance |
||
| 65 | * @param \AppserverIo\Provisioning\Configuration\ProvisionerConfigurationInterface $provisionerNode The provisioner node configuration data |
||
| 66 | */ |
||
| 67 | public function __construct(ContextInterface $initialContext, ProvisionerConfigurationInterface $provisionerNode) |
||
| 68 | { |
||
| 69 | |||
| 70 | // add initial context and provisioner node configuration data |
||
| 71 | $this->initialContext = $initialContext; |
||
| 72 | $this->provisionerNode = $provisionerNode; |
||
| 73 | |||
| 74 | // init API service to use |
||
| 75 | $this->service = $this->newService('AppserverIo\Appserver\Core\Api\ProvisioningService'); |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * (non-PHPdoc) |
||
| 80 | * |
||
| 81 | * @param string $className The API service class name to return the instance for |
||
| 82 | * |
||
| 83 | * @return \AppserverIo\Psr\ApplicationServer\ServiceInterface The service instance |
||
| 84 | * @see \AppserverIo\Psr\ApplicationServer\ContextInterface::newService() |
||
| 85 | */ |
||
| 86 | public function newService($className) |
||
| 87 | { |
||
| 88 | return $this->getInitialContext()->newService($className); |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Returns the inital context instance. |
||
| 93 | * |
||
| 94 | * @return \AppserverIo\Psr\ApplicationServer\ContextInterface The initial context instance |
||
| 95 | */ |
||
| 96 | public function getInitialContext() |
||
| 97 | { |
||
| 98 | return $this->initialContext; |
||
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Returns the service instance to use. |
||
| 103 | * |
||
| 104 | * @return \AppserverIo\Provisioning\Api\ProvisioningServiceInterface $service The service to use |
||
| 105 | */ |
||
| 106 | public function getService() |
||
| 107 | { |
||
| 108 | return $this->service; |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Returns the provisioner node configuration data. |
||
| 113 | * |
||
| 114 | * @return \AppserverIo\Provisioning\Configuration\ProvisionerConfigurationInterface The provisioner node configuration data |
||
| 115 | */ |
||
| 116 | public function getProvisionerNode() |
||
| 117 | { |
||
| 118 | return $this->provisionerNode; |
||
|
0 ignored issues
–
show
|
|||
| 119 | } |
||
| 120 | } |
||
| 121 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: