class EntityReference_SelectionHandler_Translation_Generic in Translated Entity Reference 7
A generic Entity handler.
The generic base implementation has a variety of overrides to workaround core's largely deficient entity handling.
Hierarchy
- class \EntityReference_SelectionHandler_Generic implements EntityReference_SelectionHandler
Expanded class hierarchy of EntityReference_SelectionHandler_Translation_Generic
1 string reference to 'EntityReference_SelectionHandler_Translation_Generic'
- translated_entityreference.inc in plugins/
selection/ translated_entityreference.inc
File
- plugins/
selection/ EntityReference_SelectionHandler_Translation_Generic.class.php, line 9
View source
class EntityReference_SelectionHandler_Translation_Generic extends EntityReference_SelectionHandler_Generic {
/**
* Overrides EntityReference_SelectionHandler_Generic::getInstance().
* We need to override this to be able to call our own EntityReference_SelectionHandler_Translation_Generic_node class.
*/
public static function getInstance($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
$target_entity_type = $field['settings']['target_type'];
// Check if the entity type does exist and has a base table.
$entity_info = entity_get_info($target_entity_type);
if (empty($entity_info['base table'])) {
return EntityReference_SelectionHandler_Broken::getInstance($field, $instance);
}
if (class_exists($class_name = 'EntityReference_SelectionHandler_Translation_Generic_' . $target_entity_type)) {
return new $class_name($field, $instance, $entity_type, $entity);
}
else {
return new EntityReference_SelectionHandler_Generic($field, $instance, $entity_type, $entity);
}
}
}