public static function EntityReference_SelectionHandler_Translation_Generic::getInstance in Translated Entity Reference 7
Overrides EntityReference_SelectionHandler_Generic::getInstance(). We need to override this to be able to call our own EntityReference_SelectionHandler_Translation_Generic_node class.
Overrides EntityReference_SelectionHandler_Generic::getInstance
File
- plugins/
selection/ EntityReference_SelectionHandler_Translation_Generic.class.php, line 15
Class
- EntityReference_SelectionHandler_Translation_Generic
- A generic Entity handler.
Code
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);
}
}