Security update for permissions_by_term
[yaffs-website] / vendor / drupal / drupal-driver / src / Drupal / Driver / Fields / Drupal7 / ListTextHandler.php
1 <?php
2
3 namespace Drupal\Driver\Fields\Drupal7;
4
5 /**
6  * ListText field handler for Drupal 7.
7  */
8 class ListTextHandler extends AbstractHandler {
9
10   /**
11    * {@inheritdoc}
12    */
13   public function expand($values) {
14     $return = array();
15     if (!empty($this->fieldInfo['settings']['allowed_values_function'])) {
16       $cacheable = TRUE;
17       $callback = $this->fieldInfo['settings']['allowed_values_function'];
18       $allowed_values = call_user_func($callback, $this->fieldInfo, $this, $this->entityType, $this->entity, $cacheable);
19     }
20     else {
21       $allowed_values = array();
22       $options = array_flip($this->fieldInfo['settings']['allowed_values']);
23       foreach ($values as $value) {
24         if (array_key_exists($value, $options)) {
25           $allowed_values[$value] = $options[$value];
26         }
27         else {
28           $allowed_values[$value] = $value;
29         }
30       }
31     }
32     foreach ($values as $value) {
33       $return[$this->language][] = array('value' => $allowed_values[$value]);
34     }
35     return $return;
36   }
37
38 }