/** * Overrides EntityReferenceHandler::getReferencableEntities(). * @inheritdoc */ 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']; // We imitate core by calling taxonomy_get_tree(). $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_machine_name_load($bundle)) { if ($terms = taxonomy_get_tree($vocabulary->vid, 0)) { foreach ($terms as $term) { $context = array('entity' => $term); od_entity_label_translate_factory::inst()->getTranslator('taxonomy_term', $context)->triggerEvent('pseudo_entity_load'); $options[$vocabulary->machine_name][$term->tid] = str_repeat('-', $term->depth) . check_plain($term->name); } } } } return $options; }
/** * Overrides EntityReference_SelectionHandler_Generic::settingsForm(). * 0 = Makes the filtering configurable. Either show all terms (filtered on * interface language) or show only those terms with the same language as the * referencing (parent) node. */ public static function settingsForm($field, $instance) { $form = parent::settingsForm($field, $instance); $form['filter']['language'] = array('#type' => 'select', '#title' => t('Language handling'), '#options' => array(0 => t('Select all terms matching with the interface language'), 1 => t('Select only terms matching the parent\'s language')), '#default_value' => isset($field['settings']['handler_settings']['filter']['language']) ? $field['settings']['handler_settings']['filter']['language'] : 0); return $form; }