You are here

function workflow_entity_property_info_alter in Workflow 7.2

Implements hook_entity_property_info_alter().

N.B. Keep the following functions aligned when changing properties:

File

./workflow.entity.inc, line 204
Integrates workflow with entity API.

Code

function workflow_entity_property_info_alter(&$info) {

  // Properties for Entites. @todo wrapper: not only nodes.
  //  $info['node']['properties']['workflows'] = array(
  //    'type' => 'list<Workflow>',
  //    'label' => t("Workflow"),
  //    'description' => t("The workflow of the entity."),
  //    'getter callback' => '_workflow_metadata_workflow_get_properties',
  //    'entity token' => FALSE,
  //  );
  // Properties for Workflow.
  $info['Workflow']['properties']['wid']['label'] = 'Workflow ID';
  $info['Workflow']['properties']['options']['label'] = t('Workflow options');
  $info['Workflow']['properties']['options']['getter callback'] = '_workflow_metadata_workflow_get_properties';
  $info['Workflow']['properties']['states'] = array(
    'type' => 'list<WorkflowState>',
    'label' => 'States',
    'description' => 'States of the Workflow.',
    'getter callback' => '_workflow_metadata_workflow_get_properties',
  );
  $info['Workflow']['properties']['transitions'] = array(
    'type' => 'list<WorkflowConfigTransition>',
    'label' => 'Transitions',
    'description' => 'Transitions of the Workflow.',
    'getter callback' => '_workflow_metadata_workflow_get_properties',
  );
  unset($info['Workflow']['properties']['tab_roles']['description']);
  if (!isset($info['Workflow']['properties']['tab_roles']) || !is_array($info['Workflow']['properties']['tab_roles'])) {
    $info['Workflow']['properties']['tab_roles'] = array();
  }
  $info['Workflow']['properties']['tab_roles'] += array(
    'type' => 'list<integer>',
    'label' => t("User roles"),
    'description' => t("The roles that can access the Workflow History tab."),
    'getter callback' => '_workflow_metadata_workflow_get_properties',
  );

  // Properties for WorkflowState.
  $info['WorkflowState']['properties']['wid']['type'] = 'Workflow';

  //
  $info['WorkflowState']['properties']['label'] = $info['WorkflowState']['properties']['state'];
  $info['WorkflowState']['properties']['label']['label'] = t("Label");
  $info['WorkflowState']['properties']['label']['description'] = t("The label of the state.");
  $info['WorkflowState']['properties']['label']['required'] = TRUE;
  unset($info['WorkflowState']['properties']['state']);

  // Properties for WorkflowConfigTransition.
  $info['WorkflowConfigTransition']['properties']['workflow'] = array(
    'type' => 'Workflow',
    'label' => t("Workflow"),
    'description' => t("The workflow of the transition."),
    'getter callback' => '_workflow_metadata_workflow_get_properties',
    'entity token' => FALSE,
  );
  $info['WorkflowConfigTransition']['properties']['wid'] = array(
    'type' => 'integer',
    'label' => t("Workflow  ID"),
    'description' => t("The workflow ID of the transition."),
    'getter callback' => '_workflow_metadata_workflow_get_properties',
    'entity token' => FALSE,
  );

  // @todo: Unify ID's to old_sid, new_sid.
  $info['WorkflowConfigTransition']['properties']['sid']['description'] = 'The ID of old state.';
  $info['WorkflowConfigTransition']['properties']['target_sid']['description'] = 'The ID of new state.';

  // Unify objects to old_state, new_state.
  $info['WorkflowConfigTransition']['properties']['old_state'] = array(
    'type' => 'WorkflowState',
    'label' => t('Old state'),
    'schema field' => 'sid',
    'description' => t("The old state."),
    'getter callback' => '_workflow_metadata_workflow_get_properties',
  );
  $info['WorkflowConfigTransition']['properties']['new_state'] = array(
    'type' => 'WorkflowState',
    'label' => t('New state'),
    'schema field' => 'target_sid',
    'description' => t("The new state."),
    'getter callback' => '_workflow_metadata_workflow_get_properties',
  );
  $info['WorkflowConfigTransition']['properties']['roles']['type'] = 'list<integer>';
  $info['WorkflowConfigTransition']['properties']['roles']['description'] = t("The roles that may execute the transition.");

  // Properties for WorkflowTransition.
  $info['WorkflowTransition']['properties']['label'] = $info['WorkflowConfigTransition']['properties']['label'];
  $info['WorkflowTransition']['properties']['workflow'] = $info['WorkflowConfigTransition']['properties']['workflow'];
  $info['WorkflowTransition']['properties']['wid'] = $info['WorkflowConfigTransition']['properties']['wid'];
  $info['WorkflowTransition']['properties']['hid']['label'] = 'Transition ID';

  // @todo: Unify ID's to old_sid, new_sid.
  $info['WorkflowTransition']['properties']['old_sid']['description'] = 'The ID of old state.';
  $info['WorkflowTransition']['properties']['sid']['description'] = 'The ID of new state.';

  // Unify objects to old_state, new_state.
  $info['WorkflowTransition']['properties']['old_state'] = $info['WorkflowConfigTransition']['properties']['old_state'];
  $info['WorkflowTransition']['properties']['new_state'] = $info['WorkflowConfigTransition']['properties']['new_state'];
  $info['WorkflowTransition']['properties']['user'] = array(
    'type' => 'user',
    'label' => t('User'),
    'schema field' => 'uid',
    'description' => t('The user who triggered the transition.'),
  );
  unset($info['WorkflowTransition']['properties']['stamp']);
  $info['WorkflowTransition']['properties']['timestamp'] = array(
    'type' => 'date',
    'label' => t('Timestamp'),
    'schema field' => 'stamp',
    'description' => t('The date, time the transition was executed.'),
  );
  $info['WorkflowTransition']['properties']['entity'] = array(
    'type' => 'entity',
    'label' => t('Entity'),
    'description' => t("The Entity that this state change applies to."),
    'getter callback' => '_workflow_metadata_workflow_get_properties',
  );

  // Properties for WorkflowScheduledTransition.
  $info['WorkflowScheduledTransition']['properties']['scheduled']['type'] = 'date';
  $info['WorkflowScheduledTransition']['properties']['workflow'] = $info['WorkflowTransition']['properties']['workflow'];

  // @todo: Unify ID's to old_sid, new_sid.
  $info['WorkflowScheduledTransition']['properties']['old_sid']['description'] = 'The ID of old state.';
  $info['WorkflowScheduledTransition']['properties']['sid']['description'] = 'The ID of new state.';

  // Unify objects to old_state, new_state.
  $info['WorkflowScheduledTransition']['properties']['old_state'] = $info['WorkflowTransition']['properties']['old_state'];
  $info['WorkflowScheduledTransition']['properties']['old_state']['schema field'] = 'old_sid';
  $info['WorkflowScheduledTransition']['properties']['new_state'] = $info['WorkflowTransition']['properties']['new_state'];
  $info['WorkflowScheduledTransition']['properties']['new_state']['schema field'] = 'new_sid';
  $info['WorkflowScheduledTransition']['properties']['user'] = $info['WorkflowTransition']['properties']['user'];
}