Skip to content

Commit 07cdbd9

Browse files
authored
Merge pull request #92 from itk-dev/hotfix/4719-item-deletion
4719: Made it possible to delete items
2 parents 1ecc35b + 68fa947 commit 07cdbd9

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
* [PR-92](https://github.com/itk-dev/kunstdatabasen/pull/92)
12+
4719: Made it possible to delete items
13+
1114
## [1.8.0] - 2025-05-13
1215

1316
* [PR-90](https://github.com/itk-dev/kunstdatabasen/pull/90)

config/packages/framework.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
framework:
33
secret: '%env(APP_SECRET)%'
44
#csrf_protection: true
5-
http_method_override: false
5+
http_method_override: true
66
handle_all_throwables: true
77

88
# https://symfony.com/doc/current/deployment/proxies.html

src/Controller/ItemController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,9 @@ public function edit(Request $request, Item $item, EntityManagerInterface $entit
269269
}
270270

271271
#[Route(path: '/{id}', name: 'item_delete', methods: ['DELETE'])]
272-
public function delete(Request $request, Item $item): Response
272+
public function delete(Request $request, Item $item, EntityManagerInterface $entityManager): Response
273273
{
274274
if ($this->isCsrfTokenValid('delete'.$item->getId(), $request->request->get('_token'))) {
275-
$entityManager = $this->getDoctrine()->getManager();
276275
$entityManager->remove($item);
277276
$entityManager->flush();
278277
}

src/Entity/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Item
4040
/**
4141
* @var Collection<int, Image>|Image[]
4242
*/
43-
#[ORM\OneToMany(targetEntity: Image::class, mappedBy: 'item', cascade: ['persist'])]
43+
#[ORM\OneToMany(targetEntity: Image::class, mappedBy: 'item', cascade: ['persist', 'remove'])]
4444
private Collection $images;
4545

4646
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]

0 commit comments

Comments
 (0)