| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function expand($values) { |
||
| 14 | $return = []; |
||
| 15 | foreach ($values as $name) { |
||
| 16 | $terms = \Drupal::entityTypeManager() |
||
| 17 | ->getStorage('taxonomy_term') |
||
| 18 | ->loadByProperties(['name' => $name]); |
||
| 19 | if ($terms) { |
||
| 20 | $return[] = array_shift($terms)->id(); |
||
| 21 | } |
||
| 22 | else { |
||
| 23 | throw new \Exception(sprintf("No term '%s' exists.", $name)); |
||
| 24 | } |
||
| 25 | } |
||
| 26 | return $return; |
||
| 27 | } |
||
| 28 | |||
| 30 |