Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | public function createBase64Image(string $fileName, string $fileContents, $entity) |
||
28 | { |
||
29 | $image = new Image($fileName); |
||
30 | $this->imageRepository->persist($image); |
||
31 | |||
32 | $imagesPath = $this->filePath . '/images'; |
||
33 | $filePath = sprintf('%s%s%s', $imagesPath, DIRECTORY_SEPARATOR, $fileName); |
||
34 | file_put_contents($filePath, base64_decode($fileContents)); |
||
35 | |||
36 | if ($entity instanceof Event) { |
||
37 | $entity->addImage($image); |
||
38 | } |
||
39 | |||
40 | $this->imageRepository->flush(); |
||
41 | } |
||
42 | } |
||
43 |