Conditions | 3 |
Paths | 3 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | public function expand($values) { |
||
15 | $data = file_get_contents($values[0]); |
||
16 | if (FALSE === $data) { |
||
17 | throw new \Exception("Error reading file"); |
||
18 | } |
||
19 | |||
20 | /* @var \Drupal\file\FileInterface $file */ |
||
21 | $file = file_save_data( |
||
22 | $data, |
||
23 | 'public://' . uniqid() . '.jpg'); |
||
24 | |||
25 | if (FALSE === $file) { |
||
26 | throw new \Exception("Error saving file"); |
||
27 | } |
||
28 | |||
29 | $file->save(); |
||
30 | |||
31 | $return = [ |
||
32 | 'target_id' => $file->id(), |
||
33 | 'alt' => 'Behat test image', |
||
34 | 'title' => 'Behat test image', |
||
35 | ]; |
||
36 | return $return; |
||
37 | } |
||
38 | |||
40 |