Conditions | 3 |
Paths | 3 |
Total Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function expand($values) { |
||
16 | $return = []; |
||
17 | |||
18 | foreach ($values as $value) { |
||
19 | $query = new \EntityFieldQuery(); |
||
20 | |||
21 | $query->entityCondition('entity_type', 'file') |
||
22 | ->propertyCondition('filename', $value) |
||
23 | ->propertyOrderBy('timestamp', 'DESC') |
||
24 | ->range(0, 1); |
||
25 | |||
26 | $result = $query->execute(); |
||
27 | |||
28 | if (!empty($result['file'])) { |
||
29 | $files = entity_load('file', array_keys($result['file'])); |
||
30 | $file = current($files); |
||
31 | |||
32 | $return[$this->language][] = [ |
||
33 | 'filename' => $file->filename, |
||
34 | 'uri' => $file->uri, |
||
35 | 'fid' => $file->fid, |
||
36 | 'display' => 1, |
||
37 | ]; |
||
38 | } |
||
39 | else { |
||
40 | throw new \Exception(sprintf('File with filename "%s" not found.', $value)); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | return $return; |
||
45 | } |
||
46 | |||
48 |