wernerdweight / doctrine-cascade-soft-delete-bundle
A Symfony bundle that enables your application to cascade on delete even if you're using soft-delete.
Installs: 3 287
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.1
- stof/doctrine-extensions-bundle: ^1.3
- symfony/framework-bundle: ^4.0|^5.0|^6.0
- symfony/orm-pack: ^1.0|^2.0
- thecodingmachine/safe: ^2.4
- wernerdweight/enhanced-exception: ^2.0
- wernerdweight/ra: ^2.0
Requires (Dev)
- symfony/phpunit-bridge: ^4.3|^5.0|^6.0
- thecodingmachine/phpstan-safe-rule: ^1.2
- wernerdweight/cs: ^3.0
README
A Symfony bundle that enables your application to cascade on delete even if you're using soft-delete.
Installation
1. Download using composer
composer require wernerdweight/doctrine-cascade-soft-delete-bundle
2. Enable the bundle
Enable the bundle in your kernel:
<?php // config/bundles.php return [ // ... WernerDweight\DoctrineCascadeSoftDeleteBundle\DoctrineCascadeSoftDeleteBundle::class => ['all' => true], ];
Configuration
No configuration is required. This bundle automatically extends the default behaviour and soft-deletes any related entities. Use standard Doctrine cascading options (onDelete="CASCADE|DETACH"
).
Trade-offs
To be able to cascade soft-delete, each entity must have an identifier. M:N relationship thus needs to be refactored to an entity with two 1:N relationships. If an M:N related entity is attempted to be cascaded, an exception is thrown.
Each entity that should be able to be cascaded must also be soft-deletable (i.e. has deletedAt
property).
License
This bundle is under the MIT license. See the complete license in the root directiory of the bundle.