provision.api.php 5.75 KB
Newer Older
drumm's avatar
drumm committed
1 2
<?php
/**
3 4
 * @file
 * Provision API
drumm's avatar
drumm committed
5 6
 *
 * @see drush.api.php
7
 * @see drush_command_invoke_all()
drumm's avatar
drumm committed
8 9 10
 */


11 12 13 14 15 16 17 18 19 20 21 22 23
/**
 * Implements hook_drush_load().
 *
 * In a drush contrib check if the frontend part (hosting_hook variant) is enabled.
 */
function hook_drush_load() {
  $features = drush_get_option('hosting_features', array());
  $hook_feature_name = 'something';

  return array_key_exists($hook_feature_name, $features) // Front-end module is installed...
    && $features[$hook_feature_name];                    // ... and enabled.
}

drumm's avatar
drumm committed
24 25
/**
 * Advertise what service types are available and their default
26
 * implementations. Services are class Provision_Service_{type}_{service} in
drumm's avatar
drumm committed
27 28 29 30 31 32 33 34 35 36 37 38 39
 * {type}/{service}/{service}_service.inc files.
 *
 * @return
 *   An associative array of type => default. Default may be NULL.
 *
 * @see provision.service.inc
 */
function drush_hook_provision_services() {
  return array('db' => NULL);
}

/**
 * Append PHP code to Drupal's settings.php file.
40
 *
drumm's avatar
drumm committed
41 42 43 44 45
 * To use templating, return an include statement for the template.
 *
 * @param $uri
 *   URI for the site.
 * @param $data
46
 *   Associative array of data from Provision_Config_Drupal_Settings::data.
drumm's avatar
drumm committed
47 48 49 50
 *
 * @return
 *   Lines to add to the site's settings.php file.
 *
51
 * @see Provision_Config_Drupal_Settings
drumm's avatar
drumm committed
52
 */
ergonlogic's avatar
ergonlogic committed
53
function hook_provision_drupal_config($uri, $data) {
drumm's avatar
drumm committed
54 55 56 57 58
  return '$conf[\'reverse_proxy\'] = TRUE;';
}

/**
 * Append Apache configuration to server configuration.
59
 *
drumm's avatar
drumm committed
60 61 62
 * To use templating, return an include statement for the template.
 *
 * @param $data
63
 *   Associative array of data from Provision_Config_Apache_Server::data.
drumm's avatar
drumm committed
64 65 66 67
 *
 * @return
 *   Lines to add to the configuration file.
 *
68
 * @see Provision_Config_Apache_Server
drumm's avatar
drumm committed
69 70 71 72 73 74
 */
function drush_hook_provision_apache_server_config($data) {
}

/**
 * Append Apache configuration to platform configuration.
75
 *
drumm's avatar
drumm committed
76 77 78
 * To use templating, return an include statement for the template.
 *
 * @param $data
79
 *   Associative array of data from Provision_Config_Apache_Platform::data.
drumm's avatar
drumm committed
80 81 82 83
 *
 * @return
 *   Lines to add to the configuration file.
 *
84
 * @see Provision_Config_Apache_Platform
drumm's avatar
drumm committed
85 86 87 88 89 90
 */
function drush_hook_provision_apache_dir_config($data) {
}

/**
 * Append Apache configuration to site vhost configuration.
91
 *
drumm's avatar
drumm committed
92 93 94 95 96
 * To use templating, return an include statement for the template.
 *
 * @param $uri
 *   URI for the site.
 * @param $data
97
 *   Associative array of data from Provision_Config_Apache_Site::data.
drumm's avatar
drumm committed
98 99 100 101
 *
 * @return
 *   Lines to add to the configuration file.
 *
102
 * @see Provision_Config_Apache_Site
drumm's avatar
drumm committed
103 104 105
 */
function drush_hook_provision_apache_vhost_config($uri, $data) {
}
106

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
/**
 * Append Nginx configuration to server configuration.
 *
 * To use templating, return an include statement for the template.
 *
 * @param $data
 *   Associative array of data from Provision_Config_Nginx_Server::data.
 *
 * @return
 *   Lines to add to the configuration file.
 *
 * @see Provision_Config_Nginx_Server
 */
function drush_hook_provision_nginx_server_config($data) {
}

/**
 * Append Nginx configuration to platform configuration.
 *
 * To use templating, return an include statement for the template.
 *
 * @param $data
 *   Associative array of data from Provision_Config_Nginx_Platform::data.
 *
 * @return
 *   Lines to add to the configuration file.
 *
 * @see Provision_Config_Nginx_Platform
 */
function drush_hook_provision_nginx_dir_config($data) {
}

/**
 * Append Nginx configuration to site vhost configuration.
 *
 * To use templating, return an include statement for the template.
 *
 * @param $uri
 *   URI for the site.
 * @param $data
 *   Associative array of data from Provision_Config_Nginx_Site::data.
 *
 * @return
 *   Lines to add to the configuration file.
 *
 * @see Provision_Config_Nginx_Site
 */
function drush_hook_provision_nginx_vhost_config($uri, $data) {
}

157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
/**
 * Specify a different template for rendering a config file.
 *
 * @param $config
 *   The Provision_config object trying to find its template.
 *
 * @return
 *   A filename of a template to use for rendering.
 *
 * @see hook_provision_config_load_templates_alter()
 */
function hook_provision_config_load_templates($config) {
  if (is_a($config, 'Provision_Config_Drupal_Settings')) {
    $file = dirname(__FILE__) . '/custom-php-settings.tpl.php';
    return $file;
  }
}

/**
 * Alter the templates suggested for rendering a config file.
 *
 * @param $templates
 *   The array of templates suggested by other Drush commands.
 * @param $config
 *   The Provision_config object trying to find its template.
 *
 * @see hook_provision_config_load_templates()
 */
function hook_provision_config_load_templates_alter(&$templates, $config) {
  // Don't let any custom templates be used.
  $templates = array();
}
189 190 191 192 193 194 195 196 197 198 199

/**
 * Alter the array of directories to create.
 *
 * @param $mkdir
 *    The array of directories to create.
 * @param string $url
 *    The url of the site being invoked.
 */
function hook_provision_drupal_create_directories_alter(&$mkdir, $url) {
  $mkdir["sites/$url/my_special_dir"] = 02770;
200
  $mkdir["sites/$url/my_other_dir"] = FALSE; // Skip the chmod on this directory.
201 202 203 204 205 206 207 208 209 210 211 212
}

/**
 * Alter the array of directories to change group ownership of.
 *
 * @param $chgrp
 *    The array of directories to change group ownership of.
 * @param string $url
 *    The url of the site being invoked.
 */
function hook_provision_drupal_chgrp_directories_alter(&$chgrp, $url) {
  $chgrp["sites/$url/my_special_dir"] = d('@server_master')->web_group;
213
  $chgrp["sites/$url/my_other_dir"] = FALSE; // Skip the chgrp on this directory.
214
}
215 216 217 218 219 220 221 222 223 224 225 226 227


/**
 * Alter the settings array just before starting the provision install.
 *
 * @param $settings
 *    The array with settings.
 * @param $url
 *    The site url.
 */
function hook_provision_drupal_install_settings_alter(&$settings, $url) {
  $settings['forms']['install_configure_form']['update_status_module'] = array();
}