wernerdweight/doctrine-cascade-soft-delete-bundle

A Symfony bundle that enables your application to cascade on delete even if you're using soft-delete.

2.0.0 2023-02-21 17:43 UTC

This package is auto-updated.

Last update: 2024-04-21 20:16:49 UTC


README

A Symfony bundle that enables your application to cascade on delete even if you're using soft-delete.

Build Status Latest Stable Version Total Downloads License

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.