public static function EntityReference_SelectionHandler_Generic::getInstance in Entity reference 7
Implements EntityReferenceHandler::getInstance().
Overrides EntityReference_SelectionHandler::getInstance
File
- plugins/
selection/ EntityReference_SelectionHandler_Generic.class.php, line 14
Class
- EntityReference_SelectionHandler_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_Generic_' . $target_entity_type)) {
return new $class_name($field, $instance, $entity_type, $entity);
}
else {
return new EntityReference_SelectionHandler_Generic($field, $instance, $entity_type, $entity);
}
}