install.provision.inc

  1. 7.x-3.x dns/install.provision.inc
  2. 7.x-3.x example/install.provision.inc
  3. 7.x-3.x platform/install.provision.inc
  4. 7.x-3.x db/install.provision.inc
  5. 7.x-3.x http/install.provision.inc

Drush invoke API hooks for the 'provision-install' command.

This file contains an example of how the developer is intended to interact with the services defined by the hosting-service API.

Functions

Namesort descending Description
drush_example_post_provision_install Implementation of drush_hook_post_provision_install.
drush_example_provision_install Implementation of drush_hook_provision_install.
drush_example_provision_install_rollback Implementation of drush_hook_provision_install_rollback.

File

example/install.provision.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Drush invoke API hooks for the 'provision-install' command.
  5. *
  6. * This file contains an example of how the developer is intended to
  7. * interact with the services defined by the hosting-service API.
  8. */
  9. /**
  10. * Implementation of drush_hook_provision_install.
  11. *
  12. * Create the site specific configuration for this service.
  13. *
  14. * In our basic implementation we do not have an implementation
  15. * of this API method, because it wasn't necessary.
  16. *
  17. * If the service implemented doesn't define this method, or
  18. * no implementation has been selected, nothing will happen.
  19. */
  20. function drush_example_provision_install() {
  21. /**
  22. * Using the d() accessor.
  23. *
  24. * Every object that aegir manages (namely servers, platforms and sites),
  25. * has an associated 'named context' that we manage for it.
  26. *
  27. * You can run the provision commands on different objects, simply
  28. * by specifying the context name before the drush command, such as:
  29. *
  30. * drush @server_master provision-verify
  31. *
  32. * When you have called a command in this way, you can use the d()
  33. * function without any arguments to retrieve the object representing
  34. * the current context.
  35. */
  36. if (d()->type == 'site') {
  37. // only run this code on site objects.
  38. /**
  39. * Calling service methods.
  40. *
  41. * All the provision context objects can register which
  42. * servers handle specific services for them.
  43. *
  44. * To call the correct methods, you just need to use the
  45. * the 'service' method with the service type you want
  46. * to call as its only argument.
  47. */
  48. d()->service('example')->create_config('site');
  49. }
  50. }
  51. /**
  52. * Implementation of drush_hook_provision_install_rollback.
  53. *
  54. * All drush invoke hooks allow you to recover if drush_set_error()
  55. * was set in the previously called hooks.
  56. *
  57. * By defining a _rollback variant, you can cleanly handle cases where
  58. * issues occured, in this case deleting the config file created in the
  59. * previous step.
  60. */
  61. function drush_example_provision_install_rollback() {
  62. d()->service('example')->delete_config('site');
  63. }
  64. /**
  65. * Implementation of drush_hook_post_provision_install.
  66. *
  67. * We can now perform such operations as restarting the server,
  68. * by calling the public API of the service we have created.
  69. */
  70. function drush_example_post_provision_install() {
  71. d()->service('example')->parse_configs();
  72. }