| Conditions | 4 |
| Paths | 6 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function expand($values) { |
||
| 16 | $return = []; |
||
| 17 | |||
| 18 | // Load allowed values from field storage. |
||
| 19 | $allowed_values = $this->fieldInfo->getSetting('allowed_values'); |
||
| 20 | foreach ((array) $values as $value) { |
||
| 21 | // Determine if a label matching the value is found. |
||
| 22 | $key = array_search($value, $allowed_values); |
||
| 23 | if ($key !== FALSE) { |
||
| 24 | // Set the return to use the key instead of the value. |
||
| 25 | $return[] = $key; |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | return $return ?: $values; |
||
| 30 | } |
||
| 31 | |||
| 33 |