Returns the type of a job item.
\Drupal\tmgmt\JobItemInterface $job_item: The job item.
string A type that describes the job item.
Overrides SourcePluginBase::getType
public function getType(JobItemInterface $job_item) {
if ($entity = $this
->getEntity($job_item)) {
$bundles = \Drupal::service('entity_type.bundle.info')
->getBundleInfo($job_item
->getItemType());
$entity_type = $entity
->getEntityType();
$bundle = $entity
->bundle();
// 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
->getItemType()) {
return t('@type (@bundle)', array(
'@type' => $entity_type
->getLabel(),
'@bundle' => $bundles[$bundle]['label'],
));
}
// Otherwise just display the entity type label.
return $entity_type
->getLabel();
}
}