You are here

workflow_search_api.module in Workflow 7

Same filename and directory in other branches
  1. 7.2 workflow_search_api/workflow_search_api.module

Adds workflow state information to Search API index.

File

workflow_search_api/workflow_search_api.module
View source
<?php

/**
 * @file
 * Adds workflow state information to Search API index.
 */

/**
 * Implements hook_entity_property_info_alter().
 */
function workflow_search_api_entity_property_info_alter(&$info) {
  $info['node']['properties']['workflow_state_name'] = array(
    'type' => 'text',
    'label' => t('Workflow state name'),
    'sanitized' => TRUE,
    'getter callback' => 'workflow_search_api_property_workflow_state_getter_callback',
  );
}

/**
 * Getter callback for workflow state defined in workflow_search_api_entity_property_info_alter.
 */
function workflow_search_api_property_workflow_state_getter_callback($item) {
  $state_name = '';
  if ($sid = $item->workflow) {

    // Get text value of workflow state.
    $state = WorkflowState::load($sid);
    $state_name = $state
      ->getName();
  }
  return $state_name;
}

Functions

Namesort descending Description
workflow_search_api_entity_property_info_alter Implements hook_entity_property_info_alter().
workflow_search_api_property_workflow_state_getter_callback Getter callback for workflow state defined in workflow_search_api_entity_property_info_alter.