| Conditions | 6 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function purgeImagesAction(array $params):void |
||
| 33 | { |
||
| 34 | $fullDelete = $params[0]; |
||
| 35 | $detachedImages = FileSystem::find([ |
||
| 36 | 'conditions' => 'users_id = 0 and is_deleted = 0' |
||
| 37 | ]); |
||
| 38 | |||
| 39 | if ($fullDelete == 0 && is_object($detachedImages)) { |
||
| 40 | foreach ($detachedImages as $detachedImage) { |
||
| 41 | $detachedImage->is_deleted = 1; |
||
| 42 | |||
| 43 | if ($detachedImage->update()) { |
||
| 44 | shell_exec(`rm $detachedImage->path`); |
||
| 45 | echo 'Image with id ' . $detachedImage->id . " has been soft deleted \n"; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } else { |
||
| 49 | foreach ($detachedImages as $detachedImage) { |
||
| 50 | echo 'Image with id ' . $detachedImage->id . " has been fully deleted \n"; |
||
| 51 | $detachedImage->delete(); |
||
| 52 | shell_exec(`rm $detachedImage->path`); |
||
| 53 | } |
||
| 57 |