| @@ 561-583 (lines=23) @@ | ||
| 558 | } |
|
| 559 | } |
|
| 560 | ||
| 561 | public function deleteImageByName($filename) |
|
| 562 | { |
|
| 563 | $destinationPath = realpath(__DIR__ . '/../../www/images/'); |
|
| 564 | ||
| 565 | $images = $this->getImages(); |
|
| 566 | ||
| 567 | foreach ($images as $key => $image) { |
|
| 568 | if ($image->file == $filename) { |
|
| 569 | foreach ($image->set as $imageSetFilename) { |
|
| 570 | $destination = $destinationPath . '/' . $imageSetFilename; |
|
| 571 | if (file_exists($destination)) { |
|
| 572 | unlink($destination); |
|
| 573 | } else { |
|
| 574 | dump($destination); |
|
| 575 | } |
|
| 576 | } |
|
| 577 | unset($images[$key]); |
|
| 578 | } |
|
| 579 | } |
|
| 580 | ||
| 581 | $this->repository->images = $images; |
|
| 582 | $this->save(); |
|
| 583 | } |
|
| 584 | ||
| 585 | /** |
|
| 586 | * @param $filename |
|
| @@ 709-727 (lines=19) @@ | ||
| 706 | * @param $filename |
|
| 707 | * @throws \Exception |
|
| 708 | */ |
|
| 709 | public function deleteFileByName($filename) |
|
| 710 | { |
|
| 711 | $destinationPath = realpath(__DIR__ . '/../../www/files/'); |
|
| 712 | $destination = $destinationPath . '/' . $filename; |
|
| 713 | ||
| 714 | if (file_exists($destination)) { |
|
| 715 | $files = $this->getFiles(); |
|
| 716 | foreach ($files as $key => $file) { |
|
| 717 | if ($file->file == $filename) { |
|
| 718 | unlink($destination); |
|
| 719 | unset($files[$key]); |
|
| 720 | } |
|
| 721 | } |
|
| 722 | ||
| 723 | $files = array_values($files); |
|
| 724 | $this->repository->files = $files; |
|
| 725 | $this->save(); |
|
| 726 | } |
|
| 727 | } |
|
| 728 | ||
| 729 | /* |
|
| 730 | * |
|