3 namespace Drupal\Driver\Fields\Drupal6;
5 use Drupal\Driver\Fields\FieldHandlerInterface;
8 * Provides a custom field handler to make it easier to include taxonomy terms.
10 class TaxonomyHandler implements FieldHandlerInterface {
15 public function expand($values) {
17 $values = (array) $values;
18 foreach ($values as $entry) {
19 $terms = explode(',', $entry);
20 foreach ($terms as $term) {
21 // Try to split things out in order to find optional specified vocabs.
22 $term_name_or_tid = '';
23 $parts = explode(':', $term);
24 if (count($parts) == 1) {
25 $term_name_or_tid = $term;
27 elseif (count($parts) == 2) {
28 $term_name_or_tid = $term;
30 if ($term_list = taxonomy_get_term_by_name($term_name_or_tid)) {
31 $term = reset($term_list);