hosting_example.module

Example of the Hosting Services API.

Aegir introduces an object representation of the provisioned services that need to be implemented in both it's front end and backend.

Functions

Namesort descending Description
hosting_example_feature_disable_callback Callback function to execute on enabling this module's feature.
hosting_example_feature_enable_callback Callback function to execute on enabling this module's feature.
hosting_example_hosting_service Expose a service implementation to the service API.
hosting_example_hosting_service_type Expose a type of service to the Service API.

File

example/hosting_example.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Example of the Hosting Services API.
  5. *
  6. * Aegir introduces an object representation of the provisioned
  7. * services that need to be implemented in both it's front end
  8. * and backend.
  9. */
  10. /**
  11. * @defgroup hostingserviceapi Frontend Service API
  12. * @{
  13. *
  14. * The "service API" is what makes Aegir capable of managing multiple
  15. * services like web or database servers. It provides a level of
  16. * abstraction that allows different implementations of a specific
  17. * service type.
  18. */
  19. /**
  20. * Expose a type of service to the Service API.
  21. *
  22. * Return a new type of service (such as http, dns, db etc.) to
  23. * the service API.
  24. *
  25. * This information will be used to display the server node form,
  26. * allowing you to create services of this type.
  27. *
  28. * Just defining a service type without any implementations of it,
  29. * will automatically provide the "None" implementation.
  30. *
  31. * You will then need to create a new file in the same directory
  32. * as your module named "$module.service.inc, containing at
  33. * least a single class named "provisionService_$service", which
  34. * extends the base provisionService class.
  35. *
  36. * @see hosting_server_services()
  37. * @return
  38. * an associative array with the index declaring the service
  39. * type, and containing another associative array of properties.
  40. * At present only the 'title' property is required for display
  41. * of the server node form.
  42. */
  43. function hosting_example_hosting_service_type() {
  44. return array(
  45. 'example' => array(// Machine name
  46. 'title' => t('Example service'), // Human-readable name
  47. 'weight' => 0, // Optional, defaults to 0
  48. ),
  49. );
  50. }
  51. /**
  52. * Expose a service implementation to the service API.
  53. *
  54. * Return a service implementation, such as the "apache" implementation
  55. * of the "http" service.
  56. *
  57. * An implementation class should go in {module name}.service.inc and be must be
  58. * named hostingService_{service type}_{type}, which should be a subclass of
  59. * hostingService_{service type} or hostingService.
  60. *
  61. * You will then need to either extend the existing {module name}.service.inc
  62. * file, or create a new file, containing the implementation of your service.
  63. *
  64. * @return
  65. * An associative array with the service implementation as key, and the
  66. * service type implemented as value.
  67. *
  68. * @see hosting_server_services()
  69. */
  70. function hosting_example_hosting_service() {
  71. return array('basic' => 'example'); // Service implementation => service type.
  72. }
  73. /**
  74. * @} End of "defgroup hostingserviceapi".
  75. */
  76. /**
  77. * Callback function to execute on enabling this module's feature.
  78. *
  79. * @see: hosting_example_hosting_feature().
  80. */
  81. function hosting_example_feature_enable_callback() {
  82. drupal_set_message(t("The 'example' feature's <strong>enable</strong> callback was just called."));
  83. }
  84. /**
  85. * Callback function to execute on enabling this module's feature.
  86. *
  87. * @see: hosting_example_hosting_feature().
  88. */
  89. function hosting_example_feature_disable_callback() {
  90. drupal_set_message(t("The 'example' feature's <strong>disable</strong> callback was just called."));
  91. }