Commit 12750314 authored by Jon Pugh's avatar Jon Pugh

Add allowedContexts() method for limiting what services can be subscribed to by which contexts.

parent f7322fc8
......@@ -160,7 +160,10 @@ class Context
$discovery->setSearchPattern('*Service.php');
$servicesFiles = $discovery->discover(__DIR__ .'/Service', '\Aegir\Provision\Service');
foreach ($servicesFiles as $serviceClass) {
$classes[$serviceClass::SERVICE] = $serviceClass;
// If this is a server, show all services. If it is not, but service allows this type of context, load it.
if ($this->type == 'server' || in_array($this->type, $serviceClass::allowedContexts())) {
$classes[$serviceClass::SERVICE] = $serviceClass;
}
}
if ($service && isset($classes[$service])) {
......
......@@ -27,6 +27,14 @@ class Service {
function verify() {
$this->writeConfigurations();
}
/**
* List context types that are allowed to subscribe to this service.
* @return array
*/
static function allowedContexts() {
return [];
}
/**
* Write this service's configurations.
......
......@@ -36,7 +36,17 @@ class DbService extends Service
'db_grant_all_hosts' => 'Grant access to site database users from any web host. If set to TRUE, any host will be allowed to connect to MySQL site databases on this server using the generated username and password. If set to FALSE, web hosts will be granted access by their detected IP address.',
];
}
/**
* List context types that are allowed to subscribe to this service.
* @return array
*/
static function allowedContexts() {
return [
'site'
];
}
/**
* Implements Service::server_options()
*
......
......@@ -40,6 +40,16 @@ class HttpService extends Service {
'restart_command' => 'The command to reload the web server configuration;'
];
}
/**
* List context types that are allowed to subscribe to this service.
* @return array
*/
static function allowedContexts() {
return [
'platform'
];
}
/**
* Support the ability to cloak the database credentials using environment variables.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment