| @@ 81-101 (lines=21) @@ | ||
| 78 | * Delete image by name |
|
| 79 | * @param $filename |
|
| 80 | */ |
|
| 81 | public function deleteImageByName($filename) |
|
| 82 | { |
|
| 83 | $destinationPath = $this->getDestinationPath(); |
|
| 84 | ||
| 85 | $images = $this->getImages(); |
|
| 86 | ||
| 87 | foreach ($images as $key => $image) { |
|
| 88 | if ($image->file == $filename) { |
|
| 89 | foreach ($image->set as $imageSetFilename) { |
|
| 90 | $destination = $destinationPath . '/' . $imageSetFilename; |
|
| 91 | if (file_exists($destination)) { |
|
| 92 | unlink($destination); |
|
| 93 | } |
|
| 94 | } |
|
| 95 | unset($images[$key]); |
|
| 96 | } |
|
| 97 | } |
|
| 98 | $images = array_values($images); |
|
| 99 | $this->repository->images = $images; |
|
| 100 | $this->save(); |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * @param $filename |
|
| @@ 89-107 (lines=19) @@ | ||
| 86 | * |
|
| 87 | * @throws \Exception |
|
| 88 | */ |
|
| 89 | public function deleteFileByName($filename) |
|
| 90 | { |
|
| 91 | $destinationPath = $this->getDestinationPath(); |
|
| 92 | $destination = $destinationPath . '/' . $filename; |
|
| 93 | ||
| 94 | if (file_exists($destination)) { |
|
| 95 | $files = $this->getFiles(); |
|
| 96 | foreach ($files as $key => $file) { |
|
| 97 | if ($file->file == $filename) { |
|
| 98 | unlink($destination); |
|
| 99 | unset($files[$key]); |
|
| 100 | } |
|
| 101 | } |
|
| 102 | ||
| 103 | $files = array_values($files); |
|
| 104 | $this->repository->files = $files; |
|
| 105 | $this->save(); |
|
| 106 | } |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * @return string |
|