You are here

workflow.install in Workflow 8

Install, update and uninstall functions for the workflow module.

File

workflow.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the workflow module.
 */
use Drupal\Core\Url;

/**
 * Implements hook_install().
 */
function workflow_install() {
  $url = Url::fromRoute('user.admin_permissions', [], [
    'fragment' => 'module-workflow',
  ]);
  $message = t("Thanks for using Workflow module.\n    To start using a Workflow, add a Workflow Field to your entity.\n    Please review which roles may 'participate in workflows'\n    <a href=':url'>on the Permissions page</a>.", [
    ':url' => $url
      ->toString(),
  ]);
  \Drupal::messenger()
    ->addStatus($message);
}

/**
 * Implements hook_requirements().
 *
 * Let admins know that Workflow is in use.
 *
 * @param $phase
 *
 * @return array
 */
function workflow_requirements($phase) {
  $requirements = [];
  switch ($phase) {
    case 'install':
      break;
    case 'update':
      break;
    case 'runtime':

      // @todo Show info on admin/reports/status page.

      /*
            $type_list = 'Not yet determined.';

            // $types = db_query('SELECT wid, type FROM {workflow_type_map} WHERE wid <> 0 ORDER BY type')->fetchAllKeyed();
            // If there are no types, then just bail.
            if (count($types) == 0) {
       return;
            }
            // Let's make it look nice.
            if (count($types) == 1) {
       $type_list = current($types);
            } else {
       $last = array_pop($types);
       if (count($types) > 2) {
         $type_list = implode(', ', $types) . ', and ' . $last;
       } else {
         $type_list = current($types) . ' and ' . $last;
       }
            }
      */

      /*
            $requirements['workflow'] = array(
       'title' => $t('Workflow'),
       'value' => $t('Workflow is active on the @types content types.', array('@types' => $type_list)),
       'severity' => REQUIREMENT_OK,
            );
      */
      break;
  }
  return $requirements;
}

/**
 * Implements hook_schema().
 *
 * The D8-schema's have moved to:
 * - Workflow annotation (it is a Config Entity now);
 * - WorkfowState annotation (it is a Config Entity now);
 * - WorkfowConfigTransition annotation (it is a Config Entity now);
 * - WorkflowTransition::baseFieldDefinitions();
 * - WorkflowScheduledTransition::baseFieldDefinitions().
 */
function workflow_schema() {
  return $schema = [];
}

/**
 * Drupal 8 updates.
 */

/**
 * Update from version beta1 to beta2 are not possible. Please re-install this module.
 */
function workflow_update_8001(&$sandbox) {
  \Drupal::messenger()
    ->addStatus("Update from version beta1 to beta2 is not possible. Please re-install this module.");
}

/**
 * Please check Workflow permissions "Revert own\/any state transition' and "Edit own\/any comments" before continuing.
 */
function workflow_update_8002(&$sandbox) {
  \Drupal::messenger()
    ->addStatus("Please check Workflow permissions 'Revert own/any state transition and 'Edit own/any comments' before continuing.");
}

Functions

Namesort descending Description
workflow_install Implements hook_install().
workflow_requirements Implements hook_requirements().
workflow_schema Implements hook_schema().
workflow_update_8001 Update from version beta1 to beta2 are not possible. Please re-install this module.
workflow_update_8002 Please check Workflow permissions "Revert own\/any state transition' and "Edit own\/any comments" before continuing.