function hook_hosting_servers_titles_alter in Hosting 6.2
Same name and namespace in other branches
- 7.4 server/hosting_server.api.php \hook_hosting_servers_titles_alter()
- 7.3 server/hosting_server.api.php \hook_hosting_servers_titles_alter()
Alter the servers available for selection in the frontend.
You can use this hook to modify the servers a user can choose from in the frontend when selecting things like which server to deploy a platform to, or which server to use for a site's database.
In most cases all you'll want to do is either modify the title of the server, which is for the user's informational purposes only, or remove servers so they can't choose it. Removing servers from this list may not be supported by the code getting the list of servers, so be very careful if you do this.
Parameters
$servers: An array of enabled servers, keys are the nid's of the nodes representing them, values are the titles of the servers.
$service: Service type string, like 'http' or 'db'.
See also
Related topics
1 invocation of hook_hosting_servers_titles_alter()
- hosting_get_servers in server/
hosting_server.module - Get servers providing a service.
File
- server/
hosting_server.api.php, line 33 - Hooks provided by the hosting server module.
Code
function hook_hosting_servers_titles_alter(&$servers, $service) {
// Append the string 'SERVER' to all server titles.
foreach ($servers as $nid => $title) {
$servers[$nid] .= 'SERVER';
}
// Don't allow the user to use the server with $nid == 123, for the 'db' service
if ($service == 'db') {
unset($servers[123]);
}
}