workflow.install 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the workflow module.
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function workflow_install() {
  10. $url = \Drupal\Core\Url::fromRoute('system.modules_list', [], ['fragment' => 'edit-modules-workflow']);
  11. $message = t('Thanks for using Workflow. To maintain workflows,
  12. <a href=":url">install the Workflow UI module</a>. To start using
  13. a Workflow, add a Workflow Field to your entity.',
  14. [':url' => $url->toString()]
  15. );
  16. drupal_set_message($message);
  17. }
  18. /**
  19. * Implements hook_requirements().
  20. *
  21. * Let admins know that Workflow is in use.
  22. *
  23. * @todo: extend workflow_requirements() for use with Workflow Field API.
  24. *
  25. * @param $phase
  26. * @return array
  27. */
  28. function workflow_requirements($phase) {
  29. $requirements = [];
  30. switch ($phase) {
  31. case 'install':
  32. break;
  33. case 'update':
  34. break;
  35. case 'runtime':
  36. // workflow_debug(__FILE__), __FUNCTION__, __LINE__, $form_id); // @todo D8-port: still test this snippet.
  37. /*
  38. // Show info on admin/reports/status.
  39. $type_list = 'Not yet determined.';
  40. // $types = db_query('SELECT wid, type FROM {workflow_type_map} WHERE wid <> 0 ORDER BY type')->fetchAllKeyed();
  41. // If there are no types, then just bail.
  42. if (count($types) == 0) {
  43. return;
  44. }
  45. // Let's make it look nice.
  46. if (count($types) == 1) {
  47. $type_list = current($types);
  48. } else {
  49. $last = array_pop($types);
  50. if (count($types) > 2) {
  51. $type_list = implode(', ', $types) . ', and ' . $last;
  52. } else {
  53. $type_list = current($types) . ' and ' . $last;
  54. }
  55. }
  56. */
  57. /*
  58. $requirements['workflow'] = array(
  59. 'title' => $t('Workflow'),
  60. 'value' => $t('Workflow is active on the @types content types.', array('@types' => $type_list)),
  61. 'severity' => REQUIREMENT_OK,
  62. );
  63. */
  64. break;
  65. }
  66. return $requirements;
  67. }
  68. /**
  69. * Implements hook_schema().
  70. *
  71. * The D8-schema's have moved to:
  72. * - Workflow annotation (it is a Config Entity now);
  73. * - WorkfowState annotation (it is a Config Entity now);
  74. * - WorkfowConfigTransition annotation (it is a Config Entity now);
  75. * - WorkflowTransition::baseFieldDefinitions();
  76. * - WorkflowScheduledTransition::baseFieldDefinitions().
  77. */
  78. function workflow_schema() {
  79. return $schema = [];
  80. }
  81. /**
  82. * Drupal 8 updates.
  83. */
  84. /**
  85. * Update from version beta1 to beta2 are not possible. Please re-install this module.
  86. */
  87. function workflow_update_8001(&$sandbox) {
  88. drupal_set_message("Update from version beta1 to beta2 is not possible. Please re-install this module.");
  89. }