Security update for permissions_by_term
[yaffs-website] / vendor / drupal / drupal-driver / src / Drupal / Driver / Fields / Drupal6 / TaxonomyHandler.php
1 <?php
2
3 namespace Drupal\Driver\Fields\Drupal6;
4
5 use Drupal\Driver\Fields\FieldHandlerInterface;
6
7 /**
8  * Provides a custom field handler to make it easier to include taxonomy terms.
9  */
10 class TaxonomyHandler implements FieldHandlerInterface {
11
12   /**
13    * {@inheritdoc}
14    */
15   public function expand($values) {
16     $result = array();
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;
26         }
27         elseif (count($parts) == 2) {
28           $term_name_or_tid = $term;
29         }
30         if ($term_list = taxonomy_get_term_by_name($term_name_or_tid)) {
31           $term = reset($term_list);
32           $result[] = $term;
33         }
34       }
35     }
36
37     return $result;
38   }
39
40 }