provision.api.php

Provision API

See also

drush.api.php

drush_command_invoke_all()

Functions

Namesort descending Description
drush_hook_provision_apache_dir_config Append Apache configuration to platform configuration.
drush_hook_provision_apache_server_config Append Apache configuration to server configuration.
drush_hook_provision_apache_vhost_config Append Apache configuration to site vhost configuration.
drush_hook_provision_nginx_dir_config Append Nginx configuration to platform configuration.
drush_hook_provision_nginx_server_config Append Nginx configuration to server configuration.
drush_hook_provision_nginx_vhost_config Append Nginx configuration to site vhost configuration.
drush_hook_provision_services Advertise what service types are available and their default implementations. Services are class Provision_Service_{type}_{service} in {type}/{service}/{service}_service.inc files.
hook_drush_load Implements hook_drush_load(). Deprecated. Removed in Drush 7.x.
hook_provision_config_load_templates Specify a different template for rendering a config file.
hook_provision_config_load_templates_alter Alter the templates suggested for rendering a config file.
hook_provision_deploy_options_alter Alter the options passed to 'provision-deploy' when it is invoked in restore, clone and migrate tasks.
hook_provision_drupal_chgrp_directories_alter Alter the array of directories to change group ownership of.
hook_provision_drupal_chgrp_not_recursive_directories_alter Alter the array of directories to not to recurse into in mkdir and chgrp operations.
hook_provision_drupal_chmod_not_recursive_directories_alter Alter the array of directories to not to recurse into in chmod operations.
hook_provision_drupal_config Append PHP code to Drupal's settings.php file.
hook_provision_drupal_create_directories_alter Alter the array of directories to create.
hook_provision_drupal_install_settings_alter Alter the settings array just before starting the provision install.
hook_provision_mysql_regex_alter Alter the array of regexes used to filter mysqldumps.

File

provision.api.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provision API
  5. *
  6. * @see drush.api.php
  7. * @see drush_command_invoke_all()
  8. */
  9. /**
  10. * Implements hook_drush_load(). Deprecated. Removed in Drush 7.x.
  11. *
  12. * In a drush contrib check if the frontend part (hosting_hook variant) is enabled.
  13. */
  14. function hook_drush_load() {
  15. $features = drush_get_option('hosting_features', array());
  16. $hook_feature_name = 'something';
  17. return array_key_exists($hook_feature_name, $features) // Front-end module is installed...
  18. && $features[$hook_feature_name]; // ... and enabled.
  19. }
  20. /**
  21. * Advertise what service types are available and their default
  22. * implementations. Services are class Provision_Service_{type}_{service} in
  23. * {type}/{service}/{service}_service.inc files.
  24. *
  25. * @return
  26. * An associative array of type => default. Default may be NULL.
  27. *
  28. * @see provision.service.inc
  29. */
  30. function drush_hook_provision_services() {
  31. return array('db' => NULL);
  32. }
  33. /**
  34. * Append PHP code to Drupal's settings.php file.
  35. *
  36. * To use templating, return an include statement for the template.
  37. *
  38. * @param $uri
  39. * URI for the site.
  40. * @param $data
  41. * Associative array of data from Provision_Config_Drupal_Settings::data.
  42. *
  43. * @return
  44. * Lines to add to the site's settings.php file.
  45. *
  46. * @see Provision_Config_Drupal_Settings
  47. */
  48. function hook_provision_drupal_config($uri, $data) {
  49. return '$conf[\'reverse_proxy\'] = TRUE;';
  50. }
  51. /**
  52. * Append Apache configuration to server configuration.
  53. *
  54. * To use templating, return an include statement for the template.
  55. *
  56. * The d() function is available to retrieve more information from the aegir
  57. * context.
  58. *
  59. * @param $data
  60. * Associative array of data from Provision_Config_Apache_Server::data.
  61. *
  62. * @return
  63. * Lines to add to the configuration file.
  64. *
  65. * @see Provision_Config_Apache_Server
  66. */
  67. function drush_hook_provision_apache_server_config($data) {
  68. }
  69. /**
  70. * Append Apache configuration to platform configuration.
  71. *
  72. * To use templating, return an include statement for the template.
  73. *
  74. * The d() function is available to retrieve more information from the aegir
  75. * context.
  76. *
  77. * @param $data
  78. * Associative array of data from Provision_Config_Apache_Platform::data.
  79. *
  80. * @return
  81. * Lines to add to the configuration file.
  82. *
  83. * @see Provision_Config_Apache_Platform
  84. */
  85. function drush_hook_provision_apache_dir_config($data) {
  86. }
  87. /**
  88. * Append Apache configuration to site vhost configuration.
  89. *
  90. * To use templating, return an include statement for the template.
  91. *
  92. * The d() function is available to retrieve more information from the aegir
  93. * context.
  94. *
  95. * @param $uri
  96. * URI for the site.
  97. * @param $data
  98. * Associative array of data from Provision_Config_Apache_Site::data.
  99. *
  100. * @return
  101. * Lines to add to the configuration file.
  102. *
  103. * @see Provision_Config_Apache_Site
  104. */
  105. function drush_hook_provision_apache_vhost_config($uri, $data) {
  106. }
  107. /**
  108. * Append Nginx configuration to server configuration.
  109. *
  110. * To use templating, return an include statement for the template.
  111. *
  112. * The d() function is available to retrieve more information from the aegir
  113. * context.
  114. *
  115. * @param $data
  116. * Associative array of data from Provision_Config_Nginx_Server::data.
  117. *
  118. * @return
  119. * Lines to add to the configuration file.
  120. *
  121. * @see Provision_Config_Nginx_Server
  122. */
  123. function drush_hook_provision_nginx_server_config($data) {
  124. }
  125. /**
  126. * Append Nginx configuration to platform configuration.
  127. *
  128. * To use templating, return an include statement for the template.
  129. *
  130. * The d() function is available to retrieve more information from the aegir
  131. * context.
  132. *
  133. * @param $data
  134. * Associative array of data from Provision_Config_Nginx_Platform::data.
  135. *
  136. * @return
  137. * Lines to add to the configuration file.
  138. *
  139. * @see Provision_Config_Nginx_Platform
  140. */
  141. function drush_hook_provision_nginx_dir_config($data) {
  142. }
  143. /**
  144. * Append Nginx configuration to site vhost configuration.
  145. *
  146. * To use templating, return an include statement for the template.
  147. *
  148. * The d() function is available to retrieve more information from the aegir
  149. * context.
  150. *
  151. * @param $uri
  152. * URI for the site.
  153. * @param $data
  154. * Associative array of data from Provision_Config_Nginx_Site::data.
  155. *
  156. * @return
  157. * Lines to add to the configuration file.
  158. *
  159. * @see Provision_Config_Nginx_Site
  160. */
  161. function drush_hook_provision_nginx_vhost_config($uri, $data) {
  162. }
  163. /**
  164. * Specify a different template for rendering a config file.
  165. *
  166. * @param $config
  167. * The Provision_config object trying to find its template.
  168. *
  169. * @return
  170. * A filename of a template to use for rendering.
  171. *
  172. * @see hook_provision_config_load_templates_alter()
  173. */
  174. function hook_provision_config_load_templates($config) {
  175. if (is_a($config, 'Provision_Config_Drupal_Settings')) {
  176. $file = dirname(__FILE__) . '/custom-php-settings.tpl.php';
  177. return $file;
  178. }
  179. }
  180. /**
  181. * Alter the templates suggested for rendering a config file.
  182. *
  183. * @param $templates
  184. * The array of templates suggested by other Drush commands.
  185. * @param $config
  186. * The Provision_config object trying to find its template.
  187. *
  188. * @see hook_provision_config_load_templates()
  189. */
  190. function hook_provision_config_load_templates_alter(&$templates, $config) {
  191. // Don't let any custom templates be used.
  192. $templates = array();
  193. }
  194. /**
  195. * Alter the array of directories to create.
  196. *
  197. * @param $mkdir
  198. * The array of directories to create.
  199. * @param string $url
  200. * The url of the site being invoked.
  201. */
  202. function hook_provision_drupal_create_directories_alter(&$mkdir, $url) {
  203. $mkdir["sites/$url/my_special_dir"] = 02770;
  204. $mkdir["sites/$url/my_other_dir"] = FALSE; // Skip the chmod on this directory.
  205. }
  206. /**
  207. * Alter the array of directories to change group ownership of.
  208. *
  209. * @param $chgrp
  210. * The array of directories to change group ownership of.
  211. * @param string $url
  212. * The url of the site being invoked.
  213. */
  214. function hook_provision_drupal_chgrp_directories_alter(&$chgrp, $url) {
  215. $chgrp["sites/$url/my_special_dir"] = d('@server_master')->web_group;
  216. $chgrp["sites/$url/my_other_dir"] = FALSE; // Skip the chgrp on this directory.
  217. }
  218. /**
  219. * Alter the array of directories to not to recurse into in mkdir and chgrp
  220. * operations.
  221. *
  222. * @param $chgrp_not_recursive
  223. * The array of directories not to recurse into.
  224. * @param string $url
  225. * The url of the site being invoked.
  226. */
  227. function hook_provision_drupal_chgrp_not_recursive_directories_alter($chgrp_not_recursive, $url) {
  228. $chgrp_not_recursive[] = "sites/$url/my_special_dir";
  229. unset($chgrp_not_recursive["sites/$url"]); // Allow recursion where we otherwise wouldn't.
  230. }
  231. /**
  232. * Alter the array of directories to not to recurse into in chmod operations.
  233. *
  234. * @param $chmod_not_recursive
  235. * The array of directories not to recurse into.
  236. * @param string $url
  237. * The url of the site being invoked.
  238. */
  239. function hook_provision_drupal_chmod_not_recursive_directories_alter($chmod_not_recursive, $url) {
  240. $chmod_not_recursive[] = "sites/$url/my_special_dir";
  241. unset($chmod_not_recursive["sites/$url"]); // Allow recursion where we otherwise wouldn't.
  242. }
  243. /**
  244. * Alter the settings array just before starting the provision install.
  245. *
  246. * @param $settings
  247. * The array with settings.
  248. * @param $url
  249. * The site url.
  250. */
  251. function hook_provision_drupal_install_settings_alter(&$settings, $url) {
  252. $settings['forms']['install_configure_form']['update_status_module'] = array();
  253. }
  254. /**
  255. * Alter the options passed to 'provision-deploy' when it is invoked in
  256. * restore, clone and migrate tasks.
  257. *
  258. * @param array $deploy_options
  259. * Options passed to the invocation of provision-deploy.
  260. * @param string $context
  261. * The type of task invoking the hook (e.g., 'clone').
  262. */
  263. function hook_provision_deploy_options_alter(&$deploy_options, $context) {
  264. // From hosting_s3; see: https://www.drupal.org/node/2412563
  265. // Inject the backup bucket name during the 'clone' task, so that it is
  266. // available in deploy().
  267. if ($bucket = drush_get_option('s3_backup_name', FALSE)) {
  268. $deploy_options['s3_backup_name'] = $bucket;
  269. }
  270. }
  271. /**
  272. * Alter the array of regexes used to filter mysqldumps.
  273. *
  274. * @param $regexes
  275. * An array of patterns to match (keys) and replacement patterns (values).
  276. * Setting a value to FALSE will omit the line entirely from the database
  277. * dump. Defaults are set in Provision_Service_db_mysql::get_regexes().
  278. */
  279. function hook_provision_mysql_regex_alter(&$regexes) {
  280. $regexes = array(
  281. // remove these lines entirely.
  282. '#/\*!50013 DEFINER=.*/#' => FALSE,
  283. // just remove the matched content.
  284. '#/\*!50017 DEFINER=`[^`]*`@`[^`]*`\s*\*/#' => '',
  285. // replace matched content as needed
  286. '#/\*!50001 CREATE ALGORITHM=UNDEFINED \*/#' => "/*!50001 CREATE */",
  287. );
  288. }