|
@@ -32,38 +32,21 @@
|
|
|
|
|
|
/**
|
|
|
* Implements hook_entity_info().
|
|
|
+ *
|
|
|
+ * Workflow is the bundle entity for state, but this concept is obsolete in D8,
|
|
|
+ * so we ignore it.
|
|
|
*/
|
|
|
function wing_entity_info() {
|
|
|
- $ret = array();
|
|
|
- $ret['wing_workflow'] = array(
|
|
|
- 'access callback' => 'wing_workflow_access',
|
|
|
- 'admin ui' => array(
|
|
|
- 'controller class' => 'WingWorkflowUIController',
|
|
|
- // 'file' => '',
|
|
|
- // 'file path' => '',
|
|
|
- 'menu wildcard' => '%entity_object',
|
|
|
- 'path' => 'admin/content/wing/workflow'
|
|
|
- ),
|
|
|
- 'base table' => 'wing_workflow',
|
|
|
- 'bundle of' => 'wing_state',
|
|
|
- 'controller class' => 'WingWorkflowController',
|
|
|
- 'entity class' => 'WingWorkflow',
|
|
|
+ $defaults = array(
|
|
|
'entity keys' => array(
|
|
|
- 'id' => 'wid',
|
|
|
'label' => 'title',
|
|
|
'module' => 'module',
|
|
|
- 'name' => 'name',
|
|
|
+ 'name' => 'machine_name',
|
|
|
'status' => 'status',
|
|
|
),
|
|
|
- 'export' => array(
|
|
|
- 'default hook' => 'default_wing_workflows',
|
|
|
- ),
|
|
|
'exportable' => TRUE,
|
|
|
- 'features controller class' => 'WingWorkflowFeaturesController',
|
|
|
'fieldable' => FALSE,
|
|
|
- 'label' => t('Wing: Workflow'),
|
|
|
'label callback' => 'entity_class_label',
|
|
|
- 'load hook' => 'wing_workflow_load', // Enable hook_workflow_load().
|
|
|
'module' => 'wing',
|
|
|
'uri callback' => 'entity_class_uri',
|
|
|
'view modes' => array(
|
|
@@ -80,80 +63,82 @@ function wing_entity_info() {
|
|
|
'custom settings' => FALSE,
|
|
|
),
|
|
|
),
|
|
|
- 'views controller class' => 'WingWorkflowViewsController',
|
|
|
);
|
|
|
|
|
|
- $ret['wing_state'] = array(
|
|
|
- 'access callback' => 'wing_state_access',
|
|
|
- 'admin ui' => array(
|
|
|
- 'controller class' => 'WingStateUIController',
|
|
|
- // 'file' => '',
|
|
|
- // 'file path' => '',
|
|
|
- 'menu wildcard' => '%entity_object',
|
|
|
- 'path' => 'admin/content/wing/state/%entity_object'
|
|
|
+ $ret = array();
|
|
|
+
|
|
|
+ $type = 'wing_workflow';
|
|
|
+ $class = 'WingWorkflow';
|
|
|
+ $ret[$type] = array_merge_recursive(array(
|
|
|
+ 'access callback' => "{$type}_access",
|
|
|
+ 'base table' => $type,
|
|
|
+ 'controller class' => "{$class}Controller",
|
|
|
+ 'entity class' => $class,
|
|
|
+ 'entity keys' => array(
|
|
|
+ 'id' => 'wid',
|
|
|
),
|
|
|
- 'base table' => 'wing_state',
|
|
|
+ 'export' => array(
|
|
|
+ 'default hook' => "default_{$type}s",
|
|
|
+ ),
|
|
|
+ 'features controller class' => "{$class}FeaturesController",
|
|
|
+ 'label' => t('Wing: Workflow'),
|
|
|
+ 'load hook' => "{$type}_load", // Enable hook_wing_workflow_load().
|
|
|
+ 'views controller class' => "{$class}ViewsController",
|
|
|
+ ), $defaults);
|
|
|
+
|
|
|
+ $type = 'wing_state';
|
|
|
+ $class = 'WingState';
|
|
|
+ $ret[$type] = array_merge_recursive(array(
|
|
|
+ 'access callback' => '{$type}_access',
|
|
|
+ 'base table' => $type,
|
|
|
'bundle keys' => array('bundle' => 'workflow'),
|
|
|
'bundles' => array(),
|
|
|
- 'controller class' => 'WingStateController',
|
|
|
- 'entity class' => 'WingState',
|
|
|
+ 'controller class' => "{$class}Controller",
|
|
|
+ 'entity class' => $class,
|
|
|
'entity keys' => array(
|
|
|
'id' => 'sid',
|
|
|
'bundle' => 'workflow',
|
|
|
- 'label' => 'title',
|
|
|
- 'module' => 'module',
|
|
|
- 'name' => 'name',
|
|
|
- 'status' => 'status',
|
|
|
),
|
|
|
'export' => array(
|
|
|
- 'default_hook' => 'default_wing_states',
|
|
|
+ 'default_hook' => "default_{$type}s",
|
|
|
),
|
|
|
- 'exportable' => TRUE,
|
|
|
- 'features controller class' => 'WingStateFeaturesController',
|
|
|
- 'fieldable' => TRUE,
|
|
|
+ 'features controller class' => "{$class}FeaturesController",
|
|
|
'label' => t('Wing: State'),
|
|
|
- 'label callback' => 'entity_class_label',
|
|
|
- 'load hook' => 'wing_state_load',
|
|
|
- 'module' => 'wing',
|
|
|
- 'uri callback' => 'entity_class_uri',
|
|
|
- 'view modes' => array(
|
|
|
- 'full' => array(
|
|
|
- 'label' => t('Full'),
|
|
|
- 'custom settings' => FALSE,
|
|
|
- ),
|
|
|
- 'summary' => array(
|
|
|
- 'label' => t('Summary'),
|
|
|
- 'custom settings' => FALSE,
|
|
|
- ),
|
|
|
- 'simple' => array(
|
|
|
- 'label' => t('Simple'),
|
|
|
- 'custom settings' => FALSE,
|
|
|
- ),
|
|
|
- ),
|
|
|
- 'views controller class' => 'WingStateViewsController',
|
|
|
- );
|
|
|
+ 'load hook' => "{$type}_load", // Enable hook_wing_state_load().
|
|
|
+ 'views controller class' => "{$class}ViewsController",
|
|
|
+ ), $defaults);
|
|
|
|
|
|
// Add bundle info but bypass entity_load() as we cannot use it here.
|
|
|
$workflows = db_select('wing_workflow', 'ww')
|
|
|
->fields('ww')
|
|
|
->execute()
|
|
|
- ->fetchAllAssoc('name');
|
|
|
+ ->fetchAllAssoc('machine_name');
|
|
|
|
|
|
foreach ($workflows as $workflow_name => $workflow) {
|
|
|
- $ret['wing_state']['bundles'][$workflow_name] = array(
|
|
|
+ $ret[$type]['bundles'][$workflow_name] = array(
|
|
|
'label' => $workflow->title,
|
|
|
- 'admin' => array(
|
|
|
- 'path' => 'admin/content/wing/workflow/%entity_object',
|
|
|
- 'real path' => 'admin/content/wing/workflow/' . $workflow_name,
|
|
|
- 'bundle argument' => 4,
|
|
|
- 'access arguments' => array('administer wing'),
|
|
|
- ),
|
|
|
+// 'admin' => array(
|
|
|
+// 'path' => 'admin/content/wing/workflow/%entity_object',
|
|
|
+// 'real path' => 'admin/content/wing/workflow/' . $workflow_name,
|
|
|
+// 'bundle argument' => 4,
|
|
|
+// 'access arguments' => array('administer wing'),
|
|
|
+// ),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Implements hook_entity_info_alter().
|
|
|
+ *
|
|
|
+ * Sort initial Wing entity info keys for easier debugging.
|
|
|
+ */
|
|
|
+function wing_entity_info_alter(&$info) {
|
|
|
+ ksort($info['wing_state']);
|
|
|
+ ksort($info['wing_workflow']);
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Implements hook_field_info().
|
|
|
*
|
|
@@ -173,7 +158,7 @@ function wing_field_info() {
|
|
|
// 'no_ui' => FALSE,
|
|
|
),
|
|
|
);
|
|
|
-dsm($ret);
|
|
|
+dsm($ret, __FUNCTION__);
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
@@ -227,6 +212,7 @@ function wing_menu() {
|
|
|
'page arguments' => array('wing_settings_form'),
|
|
|
'file' => 'wing.admin.inc',
|
|
|
'access arguments' => array('administer wing'),
|
|
|
+ 'weight' => 9,
|
|
|
);
|
|
|
return $items;
|
|
|
}
|
|
@@ -257,10 +243,23 @@ function wing_permission() {
|
|
|
* @return boolean
|
|
|
*/
|
|
|
function wing_state_access($op, $entity, $account, $entity_type) {
|
|
|
- dsm(get_defined_vars(), __FUNCTION__);
|
|
|
+ // dsm(get_defined_vars(), __FUNCTION__);
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Implements hook_view_api().
|
|
|
+ */
|
|
|
+function wing_views_api() {
|
|
|
+ $path = drupal_get_path('module', 'wing');
|
|
|
+ $ret = array(
|
|
|
+ 'api' => 3,
|
|
|
+ 'path' => "$path/views",
|
|
|
+ 'template path' => "$path/themes",
|
|
|
+ );
|
|
|
+ return $ret;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Entity access callback for wing_workflow.
|
|
|
*
|
|
@@ -273,6 +272,15 @@ function wing_state_access($op, $entity, $account, $entity_type) {
|
|
|
* @return boolean
|
|
|
*/
|
|
|
function wing_workflow_access($op, $entity, $account, $entity_type) {
|
|
|
- dsm(get_defined_vars(), __FUNCTION__);
|
|
|
+ $s_entity = isset($entity) ? "$entity" : 'NULL';
|
|
|
+ $s_account = isset($account) ? $account->uid : "'<anonymous>'";
|
|
|
+
|
|
|
+ // dsm(__FUNCTION__ . "('$op', $s_entity, $s_account, '$entity_type')");
|
|
|
return TRUE;
|
|
|
}
|
|
|
+
|
|
|
+function wing_workflow_exists($machine_name) {
|
|
|
+ $ret = entity_load_multiple_by_name('wing_workflow', array($machine_name));
|
|
|
+ dsm($ret, __FUNCTION__);
|
|
|
+ return $ret;
|
|
|
+}
|