| @@ 392-414 (lines=23) @@ | ||
| 389 | } |
|
| 390 | } |
|
| 391 | ||
| 392 | public function deleteImageByName($filename) |
|
| 393 | { |
|
| 394 | $destinationPath = realpath(__DIR__ . '/../../www/images/'); |
|
| 395 | ||
| 396 | $images = $this->getImages(); |
|
| 397 | ||
| 398 | foreach ($images as $key => $image) { |
|
| 399 | if ($image->file == $filename) { |
|
| 400 | foreach ($image->set as $imageSetFilename) { |
|
| 401 | $destination = $destinationPath . '/' . $imageSetFilename; |
|
| 402 | if (file_exists($destination)) { |
|
| 403 | unlink($destination); |
|
| 404 | } else { |
|
| 405 | dump($destination); |
|
| 406 | } |
|
| 407 | } |
|
| 408 | unset($images[$key]); |
|
| 409 | } |
|
| 410 | } |
|
| 411 | ||
| 412 | $this->repository->images = $images; |
|
| 413 | $this->save(); |
|
| 414 | } |
|
| 415 | ||
| 416 | /** |
|
| 417 | * @param $filename |
|
| @@ 548-566 (lines=19) @@ | ||
| 545 | * |
|
| 546 | * @throws \Exception |
|
| 547 | */ |
|
| 548 | public function deleteFileByName($filename) |
|
| 549 | { |
|
| 550 | $destinationPath = realpath(__DIR__ . '/../../www/files/'); |
|
| 551 | $destination = $destinationPath . '/' . $filename; |
|
| 552 | ||
| 553 | if (file_exists($destination)) { |
|
| 554 | $files = $this->getFiles(); |
|
| 555 | foreach ($files as $key => $file) { |
|
| 556 | if ($file->file == $filename) { |
|
| 557 | unlink($destination); |
|
| 558 | unset($files[$key]); |
|
| 559 | } |
|
| 560 | } |
|
| 561 | ||
| 562 | $files = array_values($files); |
|
| 563 | $this->repository->files = $files; |
|
| 564 | $this->save(); |
|
| 565 | } |
|
| 566 | } |
|
| 567 | ||
| 568 | /* |
|
| 569 | * |
|