| @@ 456-474 (lines=19) @@ | ||
| 453 | * |
|
| 454 | * @throws \Exception |
|
| 455 | */ |
|
| 456 | public function deleteFileByName($filename) |
|
| 457 | { |
|
| 458 | $destinationPath = realpath(__DIR__ . '/../../www/files/'); |
|
| 459 | $destination = $destinationPath . '/' . $filename; |
|
| 460 | ||
| 461 | if (file_exists($destination)) { |
|
| 462 | $files = $this->getFiles(); |
|
| 463 | foreach ($files as $key => $file) { |
|
| 464 | if ($file->file == $filename) { |
|
| 465 | unlink($destination); |
|
| 466 | unset($files[$key]); |
|
| 467 | } |
|
| 468 | } |
|
| 469 | ||
| 470 | $files = array_values($files); |
|
| 471 | $this->repository->files = $files; |
|
| 472 | $this->save(); |
|
| 473 | } |
|
| 474 | } |
|
| 475 | ||
| 476 | /* |
|
| 477 | * |
|
| @@ 65-87 (lines=23) @@ | ||
| 62 | * Delete image by name |
|
| 63 | * @param $filename |
|
| 64 | */ |
|
| 65 | public function deleteImageByName($filename) |
|
| 66 | { |
|
| 67 | $destinationPath = realpath(__DIR__ . '/../../../www/images/'); |
|
| 68 | ||
| 69 | $images = $this->getImages(); |
|
| 70 | ||
| 71 | foreach ($images as $key => $image) { |
|
| 72 | if ($image->file == $filename) { |
|
| 73 | foreach ($image->set as $imageSetFilename) { |
|
| 74 | $destination = $destinationPath . '/' . $imageSetFilename; |
|
| 75 | if (file_exists($destination)) { |
|
| 76 | unlink($destination); |
|
| 77 | } else { |
|
| 78 | dump($destination); |
|
| 79 | } |
|
| 80 | } |
|
| 81 | unset($images[$key]); |
|
| 82 | } |
|
| 83 | } |
|
| 84 | ||
| 85 | $this->repository->images = $images; |
|
| 86 | $this->save(); |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * @param $filename |
|