Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function prepareRow(Row $row) { |
||
18 | if ($image = $row->getSourceProperty('Image')) { |
||
19 | $files = \Drupal::entityTypeManager() |
||
20 | ->getStorage('file')->loadByProperties(['filename' => $image]); |
||
21 | |||
22 | if (empty($files)) { |
||
23 | $base_path = dirname($this->configuration['path']) . '/images/'; |
||
24 | $path = $base_path . $image; |
||
25 | $data = file_get_contents($path); |
||
26 | $uri = file_build_uri($image); |
||
27 | $file = file_save_data($data, $uri); |
||
28 | } |
||
29 | else { |
||
30 | $file = reset($files); |
||
31 | } |
||
32 | |||
33 | $row->setSourceProperty('File', $file); |
||
34 | } |
||
38 |