Skip to content
......@@ -11,6 +11,7 @@ namespace Aegir\Provision\Service;
//require_once DRUSH_BASE_PATH . '/commands/core/rsync.core.inc';
use Aegir\Provision\Service;
use Aegir\Provision\ServiceInterface;
use Aegir\Provision\ServiceSubscription;
use Consolidation\AnnotatedCommand\CommandFileDiscovery;
......@@ -19,7 +20,7 @@ use Consolidation\AnnotatedCommand\CommandFileDiscovery;
*
* @package Aegir\Provision\Service
*/
class HttpService extends Service {
class HttpService extends Service implements ServiceInterface {
const SERVICE = 'http';
const SERVICE_NAME = 'Web Server';
......@@ -57,7 +58,7 @@ class HttpService extends Service {
*
* This is used to allow skipping of the service restart.
*/
function verifyProvider()
function verifyServer()
{
return [
'configuration' => $this->writeConfigurations(),
......@@ -67,14 +68,18 @@ class HttpService extends Service {
/**
* React to the `provision verify` command on Server contexts
*/
function verifySubscription(ServiceSubscription $serviceSubscription) {
$this->subscription = $serviceSubscription;
function verifySite() {
$this->subscription = $this->getContext()->getSubscription();
return [
'configuration' => $this->writeConfigurations($serviceSubscription),
'configuration' => $this->writeConfigurations($this->subscription),
'service' => $this->restartService(),
];
}
//
function verifyPlatform() {
}
//
// /**
// * Support the ability to cloak the database credentials using environment variables.
// */
......
<?php
namespace Aegir\Provision;
interface ServiceInterface
{
/**
* Triggered on `provision verify` command on Site contexts.
*/
public function verifySite();
/**
* Triggered on `provision verify` command on Platform contexts.
*/
public function verifyPlatform();
/**
* Triggered on `provision verify` command on Site contexts.
*/
public function verifyServer();
}
\ No newline at end of file
......@@ -9,6 +9,9 @@
namespace Aegir\Provision;
use Aegir\Provision\Common\ContextAwareTrait;
use Aegir\Provision\Common\ProvisionAwareTrait;
class ServiceSubscription {
public $context;
......@@ -16,10 +19,19 @@ class ServiceSubscription {
public $server;
public $type;
public $properties = [];
use ProvisionAwareTrait;
use ContextAwareTrait;
function __construct($context, $server, $service_name) {
$this->context = $context;
$this->server = Application::getContext($server, $context->application);
function __construct(
Context $context,
$server,
$service_name
) {
$this->setContext($context);
$this->setProvision($context->getProvision());
$this->server = $this->getProvision()->getContext($server);
$this->service = $this->server->getService($service_name);
$this->type = $this->server->getService($service_name)->type;
......@@ -35,4 +47,21 @@ class ServiceSubscription {
public function getFriendlyName() {
return $this->service->getFriendlyName();
}
/**
* Get a specific property.
*
* @param $name
* @return mixed
* @throws \Exception
*/
public function getProperty($name) {
if (isset($this->properties[$name])) {
return $this->properties[$name];
}
else {
throw new \Exception("Property '$name' on Service Subscription does not exist.");
}
}
}