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