You are here

public function TMGMTEntitySourcePluginController::getType in Translation Management Tool 7

Returns the type of a job item.

Parameters

TMGMTJobItem $job_item: The job item.

Return value

string A type that describes the job item.

Overrides TMGMTDefaultSourcePluginController::getType

File

sources/entity/tmgmt_entity.plugin.inc, line 69
Provides the Entity source controller.

Class

TMGMTEntitySourcePluginController
@file Provides the Entity source controller.

Code

public function getType(TMGMTJobItem $job_item) {
  if ($entity = entity_load_single($job_item->item_type, $job_item->item_id)) {
    $bundles = tmgmt_entity_get_translatable_bundles($job_item->item_type);
    $info = entity_get_info($job_item->item_type);
    list(, , $bundle) = entity_extract_ids($job_item->item_type, $entity);

    // Display entity type and label if we have one and the bundle isn't
    // the same as the entity type.
    if (isset($bundles[$bundle]) && $bundle != $job_item->item_type) {
      return t('@type (@bundle)', array(
        '@type' => $info['label'],
        '@bundle' => $bundles[$bundle],
      ));
    }
    elseif (isset($info['label'])) {
      return $info['label'];
    }
    return parent::getType($job_item);
  }
}