PHPackages                             stichtingsd/soft-deleteable-extension-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. stichtingsd/soft-deleteable-extension-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

stichtingsd/soft-deleteable-extension-bundle
============================================

Extension to Gedmo Softdeleteable.

2.0.0(1y ago)34.6k↓26.7%1[1 issues](https://github.com/stichtingsd/softdeleteable-extension-bundle/issues)[1 PRs](https://github.com/stichtingsd/softdeleteable-extension-bundle/pulls)1MITPHPPHP &gt;=8.3

Since Jan 6Pushed 1y ago3 watchersCompare

[ Source](https://github.com/stichtingsd/softdeleteable-extension-bundle)[ Packagist](https://packagist.org/packages/stichtingsd/soft-deleteable-extension-bundle)[ RSS](/packages/stichtingsd-soft-deleteable-extension-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (15)Versions (6)Used By (1)

SoftDeleteableExtensionBundle
=============================

[](#softdeleteableextensionbundle)

Warning: This bundle only works with Symfony ^6.4 || ^7.2 and PHP ^8.3
----------------------------------------------------------------------

[](#warning-this-bundle-only-works-with-symfony-64--72-and-php-83)

---

This bundle is created to handle soft deletes for associated entities/documents in addition to the functionality of Gedmo SoftDelete. Gedmo does not handle CASCADING relations for example. Doctrine doesn't also since it's not actually deleted.

The bundle also handles deletion of large entities very well thanks to Doctrine DQL and Proxy objects. Entities that have 10.000+ relations are updated in a split second.

Prerequisites
-------------

[](#prerequisites)

**This bundle requires Symfony ^6.4 || ^7.2 or higher and PHP ^8.3 or higher**

- Symfony ^6.4 || ^7.2
- PHP ^8.4
- gedmo/doctrine-extensions ^3.16

Installation
------------

[](#installation)

Add stichtingsd/soft-deleteable-extension-bundle to your `composer.json` file:

```
composer require "stichtingsd/soft-deleteable-extension-bundle"

```

### Bundle registration (Skip when using Symfony Flex)

[](#bundle-registration-skip-when-using-symfony-flex)

Register bundle into config/bundles.php (Flex does it automatically):

```
# config/bundles.php

return [
    ...
    new StichtingSD\SoftDeleteableExtensionBundle\StichtingSDSoftDeleteableExtensionBundle(),
];
```

Getting started
---------------

[](#getting-started)

**Cascade soft deletedelete the entity**

To (soft-)delete an entity when its parent record is soft-deleted:

```
use StichtingSD\SoftDeleteableExtensionBundle\Mapping\Attribute as StichtingSD;
use StichtingSD\SoftDeleteableExtensionBundle\Mapping\Type;

...

#[StichtingSD\onSoftDelete(type: Type::CASCADE)]

```

Set reference to null (instead of deleting the entity)

```
use StichtingSD\SoftDeleteableExtensionBundle\Mapping\Attribute as StichtingSD;
use StichtingSD\SoftDeleteableExtensionBundle\Mapping\Type;

...

#[StichtingSD\onSoftDelete(type: Type::SET_NULL)]

```

### Supported association types:

[](#supported-association-types)

- One-To-One
    - Type::CASCADE
    - Type::SET\_NULL
- Many-To-One
    - Type::CASCADE
    - Type::SET\_NULL
- Many-To-Many
    - Type::REMOVE\_ASSOCIATION\_ONLY

#### Type::CASCADE

[](#typecascade)

This behaves like the SQL CASCADE. All relations that have a soft deleteable field from Gedmo will be deleted also.

#### Type::SET\_NULL

[](#typeset_null)

This behaves like the SQL SET\_NULL. The relation will be set to NULL.
*Caution: Your field must be `nullable: true` to allow null values.*

#### Type::REMOVE\_ASSOCIATION\_ONLY

[](#typeremove_association_only)

This will remove the association only. Associated entities them self are not deleted since they can have other associations.

### Full example Many-To-One

[](#full-example-many-to-one)

```
