Conditions | 4 |
Paths | 6 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
13 | public function expand($values) { |
||
14 | $entity_type = $this->fieldInfo['settings']['target_type']; |
||
15 | $entity_info = entity_get_info($entity_type); |
||
16 | // For users set label to username. |
||
17 | if ($entity_type == 'user') { |
||
18 | $entity_info['entity keys']['label'] = 'name'; |
||
19 | } |
||
20 | |||
21 | $return = []; |
||
22 | foreach ($values as $value) { |
||
23 | $target_id = db_select($entity_info['base table'], 't') |
||
24 | ->fields('t', [$entity_info['entity keys']['id']]) |
||
25 | ->condition('t.' . $entity_info['entity keys']['label'], $value) |
||
26 | ->execute()->fetchField(); |
||
27 | if ($target_id) { |
||
28 | $return[$this->language][] = ['target_id' => $target_id]; |
||
29 | } |
||
30 | } |
||
31 | return $return; |
||
32 | } |
||
33 | |||
35 |