function workflow_entity_info in Workflow 7.2
Implements hook_entity_info().
@todo: implement hook_property_info, metadata.
File
- ./
workflow.entity.inc, line 13 - Integrates workflow with entity API.
Code
function workflow_entity_info() {
$entities['Workflow'] = array(
'label' => t('Workflow'),
'plural label' => t('Workflows'),
'entity class' => 'Workflow',
'controller class' => 'WorkflowController',
'metadata controller class' => 'EntityDefaultMetadataController',
'features controller class' => 'WorkflowFeaturesController',
'module' => 'workflow',
'base table' => 'workflows',
// Make WorkflowTransition fieldable. The wid is the Transition Type.
'fieldable' => FALSE,
'bundle of' => 'WorkflowTransition',
'exportable' => TRUE,
'entity keys' => array(
'id' => 'wid',
'name' => 'name',
),
'label callback' => 'entity_class_label',
'uri callback' => 'entity_class_uri',
);
$entities['WorkflowState'] = array(
'label' => t('Workflow state'),
'entity class' => 'WorkflowState',
'controller class' => 'WorkflowStateController',
'metadata controller class' => 'EntityDefaultMetadataController',
// 'features controller class' => FALSE, //@todo: implement this.
'module' => 'workflow',
'base table' => 'workflow_states',
'fieldable' => FALSE,
'exportable' => FALSE,
'entity keys' => array(
'id' => 'sid',
),
'label callback' => 'entity_class_label',
'uri callback' => 'entity_class_uri',
);
$entities['WorkflowConfigTransition'] = array(
'label' => t('Workflow config transition'),
'entity class' => 'WorkflowConfigTransition',
// Add controller Class. 'Workflow' class is the de-facto controller.
'controller class' => 'WorkflowConfigTransitionController',
'metadata controller class' => 'EntityDefaultMetadataController',
'base table' => 'workflow_transitions',
'exportable' => FALSE,
'module' => 'workflow',
'entity keys' => array(
'id' => 'tid',
'status' => 'status',
),
'label callback' => 'entity_class_label',
);
// The Controller class of Transitions and ScheduledTransition is shared.
$entities['WorkflowTransition'] = array(
'label' => t('Workflow executed transition'),
'entity class' => 'WorkflowTransition',
'controller class' => 'WorkflowTransitionController',
'metadata controller class' => 'EntityDefaultMetadataController',
// Do not use 'extra fields controller class'. Use hook_field_extra_fields instead.
// 'extra fields controller class' => 'EntityDefaultExtraFieldsController',
'views controller class' => 'EntityDefaultViewsController',
'rules controller class' => 'EntityDefaultRulesController',
'features controller class' => FALSE,
'base table' => 'workflow_node_history',
'fieldable' => TRUE,
// Bundles are defined by the $types below.
'bundles' => array(),
// Bundle keys tell the FieldAPI how to extract information from the bundle objects.
'bundle keys' => array(
'bundle' => 'wid',
),
// 'admin ui' => array(
// 'path' => WORKFLOW_ADMIN_UI_PATH . '/manage/%workflow_transition/fields2',
// 'menu wildcard' => '%workflow_transition',
// 'controller class' => 'EntityDefaultUIController',
// ),
'entity keys' => array(
'id' => 'hid',
'bundle' => 'wid',
),
'label callback' => 'entity_class_label',
'module' => 'workflow',
);
// Add bundle info but bypass entity_load() as we cannot use it here.
// (The bundle-setup is copied from the D7 entityform module.)
// Get all workflows, keyed by wid.
// Use try..catch.. to workaround #1311820, @see #2484325.
try {
// Add bundle info but bypass entity_load() as we cannot use it here.
// (The bundle-setup is copied from the D7 entityform module.)
// Get all workflows, keyed by wid.
$types = db_select('workflows', 'w')
->fields('w')
->execute()
->fetchAllAssoc('wid');
} catch (PDOException $ex) {
watchdog('workflow', 'Failed to retrieve workflow types: %exception', array(
'%exception' => (string) $ex,
), WATCHDOG_ERROR);
$types = array();
}
// Build an array of bundles.
foreach ($types as $wid => $info) {
$entities['WorkflowTransition']['bundles'][$wid] = array(
'label' => $info->label,
'admin' => array(
'path' => WORKFLOW_ADMIN_UI_PATH . '/manage/%workflow',
'real path' => WORKFLOW_ADMIN_UI_PATH . "/manage/{$wid}",
'bundle argument' => 5,
),
);
}
$entities['WorkflowScheduledTransition'] = array(
'label' => t('Workflow scheduled transition'),
'entity class' => 'WorkflowScheduledTransition',
'controller class' => 'WorkflowTransitionController',
'metadata controller class' => 'EntityDefaultMetadataController',
'views controller class' => 'EntityDefaultViewsController',
'rules controller class' => 'EntityDefaultRulesController',
'features controller class' => FALSE,
'base table' => 'workflow_scheduled_transition',
'entity keys' => array(
'id' => 'tid',
),
'label callback' => 'entity_class_label',
'module' => 'workflow',
);
return $entities;
}