Brille24 / SyliusCustomOptionsPlugin

A Sylius plugin that adds customer options
MIT License
47 stars 34 forks source link

Turn resources from entity to mapped-superclass & cascade deletions #138

Closed JakobTolkemit closed 1 year ago

JakobTolkemit commented 1 year ago

Makes our resource entities extendable. Also some deletions didn't get cascaded outside of doctrine.

mamazu commented 1 year ago

But why do we want to cascade those things? Are you accidentally trying to delete orders?

JakobTolkemit commented 1 year ago

Our unit tests run the \Doctrine\Common\DataFixtures\Purger\ORMPurger before every test. That's where we run into failing foreign key checks.

Turns out, we currently deal with that, by extending the \Tests\Sylius\ShopApiPlugin\Controller\JsonApiTestCase and turning off foreign key checks for the purge.

seizan8 commented 1 year ago

Am I misunderstanding the configs? Does the cascade mean it gets cascaded to the configured entity or said entity will cascade to related one?

To me it looks like deleting a CustomerOptionValuePrice would also remove the Product. Which should never happen. Or removing a Translation will also remove the main object. If that's the case, the cascade should be inversed and on the other side.

If I'm wrong tho, I think this is fine.

JakobTolkemit commented 1 year ago

It's the other way around. When the main object gets deleted, we also remove the translation, and when the product gets deleted we also remove the CustomerOptionValuePrice that was created for that product.

mamazu commented 1 year ago

Looks good to me, merge it and tag it?