workflow.install 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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_uninstall().
  20. */
  21. function workflow_uninstall() {
  22. // \Drupal::config('workflow.settings')->clear('workflow_states_per_page')->save(); // @FIXME
  23. }
  24. /**
  25. * Implements hook_requirements().
  26. *
  27. * Let admins know that Workflow is in use.
  28. *
  29. * @todo: extend workflow_requirements() for use with Workflow Field API.
  30. *
  31. * @param $phase
  32. * @return array
  33. */
  34. function workflow_requirements($phase) {
  35. $requirements = [];
  36. switch ($phase) {
  37. case 'install':
  38. break;
  39. case 'update':
  40. break;
  41. case 'runtime':
  42. // workflow_debug(__FILE__), __FUNCTION__, __LINE__, $form_id); // @todo D8-port: still test this snippet.
  43. /*
  44. // Show info on admin/reports/status.
  45. $type_list = 'Not yet determined.';
  46. // $types = db_query('SELECT wid, type FROM {workflow_type_map} WHERE wid <> 0 ORDER BY type')->fetchAllKeyed();
  47. // If there are no types, then just bail.
  48. if (count($types) == 0) {
  49. return;
  50. }
  51. // Let's make it look nice.
  52. if (count($types) == 1) {
  53. $type_list = current($types);
  54. } else {
  55. $last = array_pop($types);
  56. if (count($types) > 2) {
  57. $type_list = implode(', ', $types) . ', and ' . $last;
  58. } else {
  59. $type_list = current($types) . ' and ' . $last;
  60. }
  61. }
  62. */
  63. /*
  64. $requirements['workflow'] = array(
  65. 'title' => $t('Workflow'),
  66. 'value' => $t('Workflow is active on the @types content types.', array('@types' => $type_list)),
  67. 'severity' => REQUIREMENT_OK,
  68. );
  69. */
  70. break;
  71. }
  72. return $requirements;
  73. }
  74. /**
  75. * Implements hook_schema().
  76. *
  77. * The D8-schema's have moved to:
  78. * - Workflow annotation (it is a Config Entity now);
  79. * - WorkfowState annotation (it is a Config Entity now);
  80. * - WorkfowConfigTransition annotation (it is a Config Entity now);
  81. * - WorkflowTransition::baseFieldDefinitions();
  82. * - WorkflowScheduledTransition::baseFieldDefinitions().
  83. */
  84. function workflow_schema() {
  85. return $schema = [];
  86. }
  87. /**
  88. * Drupal 8 updates.
  89. */
  90. /**
  91. * Update from version beta1 to beta2 are not possible. Please re-install this module.
  92. */
  93. function workflow_update_8001(&$sandbox) {
  94. drupal_set_message("Update from version beta1 to beta2 is not possible. Please re-install this module.");
  95. }