You are here

hosting_example.module in Hosting 6.2

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.

File

example/hosting_example.module
View source
<?php

/**
 * @file
 * 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.
 */

/**
 * @defgroup hostingserviceapi Frontend Service API
 * @{
 *
 * The "service API" is what makes Aegir capable of managing multiple
 * services like web or database servers. It provides a level of
 * abstraction that allows different implementations of a specific
 * service type.
 */

/**
 * Expose a type of service to the Service API.
 *
 * Return a new type of service (such as http, dns, db etc.) to
 * the service API.
 *
 * This information will be used to display the server node form,
 * allowing you to create services of this type.
 *
 * Just defining a service type without any implementations of it,
 * will automatically provide the "None" implementation.
 *
 * You will then need to create a new file in the same directory
 * as your module named "$module.service.inc, containing at
 * least a single class named "provisionService_$service", which
 * extends the base provisionService class.
 *
 * @see hosting_server_services()
 * @return
 *    an associative array with the index declaring the service
 *    type, and containing another associative array of properties.
 *    At present only the 'title' property is required for display
 *    of the server node form.
 */
function hosting_example_hosting_service_type() {
  return array(
    'example' => array(
      // Machine name
      'title' => t('Example service'),
      // Human-readable name
      'weight' => 0,
    ),
  );
}

/**
 * Expose a service implementation to the service API.
 *
 * Return a service implementation, such as the "apache" implementation
 * of the "http" service.
 *
 * An implementation class should go in {module name}.service.inc and be must be
 * named hostingService_{service type}_{type}, which should be a subclass of
 * hostingService_{service type} or hostingService.
 *
 * You will then need to either extend the existing {module name}.service.inc
 * file, or create a new file, containing the implementation of your service.
 *
 * @return
 *   An associative array with the service implementation as key, and the
 *   service type implemented as value.
 *
 * @see hosting_server_services()
 */
function hosting_example_hosting_service() {
  return array(
    'basic' => 'example',
  );

  // Service implementation => service type.
}

/**
 * @} End of "defgroup hostingserviceapi".
 */

/**
 * Callback function to execute on enabling this module's feature.
 *
 * @see: hosting_example_hosting_feature().
 */
function hosting_example_feature_enable_callback() {
  drupal_set_message(t("The 'example' feature's <strong>enable</strong> callback was just called."));
}

/**
 * Callback function to execute on enabling this module's feature.
 *
 * @see: hosting_example_hosting_feature().
 */
function hosting_example_feature_disable_callback() {
  drupal_set_message(t("The 'example' feature's <strong>disable</strong> callback was just called."));
}

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.