| @@ 796-818 (lines=23) @@ | ||
| 793 | } |
|
| 794 | } |
|
| 795 | ||
| 796 | public function deleteImageByName($filename) |
|
| 797 | { |
|
| 798 | $destinationPath = realpath(__DIR__ . '/../../www/images/'); |
|
| 799 | ||
| 800 | $images = $this->getImages(); |
|
| 801 | ||
| 802 | foreach ($images as $key => $image) { |
|
| 803 | if ($image->file == $filename) { |
|
| 804 | foreach ($image->set as $imageSetFilename) { |
|
| 805 | $destination = $destinationPath . '/' . $imageSetFilename; |
|
| 806 | if (file_exists($destination)) { |
|
| 807 | unlink($destination); |
|
| 808 | } else { |
|
| 809 | dump($destination); |
|
| 810 | } |
|
| 811 | } |
|
| 812 | unset($images[$key]); |
|
| 813 | } |
|
| 814 | } |
|
| 815 | ||
| 816 | $this->repository->images = $images; |
|
| 817 | $this->save(); |
|
| 818 | } |
|
| 819 | ||
| 820 | /** |
|
| 821 | * @param $filename |
|
| @@ 929-947 (lines=19) @@ | ||
| 926 | * @param $filename |
|
| 927 | * @throws \Exception |
|
| 928 | */ |
|
| 929 | public function deleteFileByName($filename) |
|
| 930 | { |
|
| 931 | $destinationPath = realpath(__DIR__ . '/../../www/files/'); |
|
| 932 | $destination = $destinationPath . '/' . $filename; |
|
| 933 | ||
| 934 | if (file_exists($destination)) { |
|
| 935 | $files = $this->getFiles(); |
|
| 936 | foreach ($files as $key => $file) { |
|
| 937 | if ($file->file == $filename) { |
|
| 938 | unlink($destination); |
|
| 939 | unset($files[$key]); |
|
| 940 | } |
|
| 941 | } |
|
| 942 | ||
| 943 | $files = array_values($files); |
|
| 944 | $this->repository->files = $files; |
|
| 945 | $this->save(); |
|
| 946 | } |
|
| 947 | } |
|
| 948 | ||
| 949 | /* |
|
| 950 | * |
|