diff --git a/src/Context.php b/src/Context.php index 641ce086a52181236bc8ac21cddbf2e2261a00cf..71897e884502fe389302699ad4e1dd0f0d664ae3 100644 --- a/src/Context.php +++ b/src/Context.php @@ -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])) { diff --git a/src/Service.php b/src/Service.php index d253cd39c3182393aca4bfd402f56a76030ee22e..f78055259263158f0a6b82f7dd2d3270883b3d54 100644 --- a/src/Service.php +++ b/src/Service.php @@ -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. diff --git a/src/Service/DbService.php b/src/Service/DbService.php index 7042a68581163d923bc5a14f31fa607dcc196bf2..8988e7a2e6535111fff799e969483deaab900c9d 100644 --- a/src/Service/DbService.php +++ b/src/Service/DbService.php @@ -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() * diff --git a/src/Service/HttpService.php b/src/Service/HttpService.php index 0fbdc7a7e5a77fa4210818b1ff426e27c91505bf..af6ce4906d6c7865059745674b8240314e473488 100644 --- a/src/Service/HttpService.php +++ b/src/Service/HttpService.php @@ -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.