1 EntityReferenceSelectionHandlerGeneric.inc | public EntityReferenceSelectionHandlerGeneric_taxonomy_term::getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) |
Implements EntityReferenceHandler::getReferencableEntities().
Overrides EntityReferenceSelectionHandlerGeneric::getReferencableEntities
File
- core/
modules/ entityreference/ plugins/ selection/ EntityReferenceSelectionHandlerGeneric.inc, line 532 - Generic Entity handler.
Class
- EntityReferenceSelectionHandlerGeneric_taxonomy_term
- Override for the Taxonomy term entity type.
Code
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
if ($match || $limit) {
return parent::getReferencableEntities($match, $match_operator, $limit);
}
$options = array();
$entity_type = $this->field['settings']['target_type'];
$entity_info = entity_get_info('taxonomy_term');
$bundles = !empty($this->field['settings']['handler_settings']['target_bundles']) ? $this->field['settings']['handler_settings']['target_bundles'] : array_keys($entity_info['bundles']);
foreach ($bundles as $bundle) {
if ($vocabulary = taxonomy_vocabulary_load($bundle)) {
if ($terms = taxonomy_get_tree($vocabulary->machine_name, 0, NULL, TRUE)) {
foreach ($terms as $term) {
$options[$vocabulary->machine_name][$term->tid] = str_repeat('-', $term->depth) . check_plain(entity_label('taxonomy_term', $term));
}
}
}
}
return $options;
}