StodeDoctrineExtensionsBundle softdelete - How to use it?

My boss installed this package for the softdelete filter, but the documentation goes beyond sparsity. How to use this in my delete requests?

+8
php symfony stofdoctrineextensions
source share
2 answers

Enable it in your configuration:

stof_doctrine_extensions: orm: default: ... softdeleteable: true doctrine: ... orm: filters: softdeleteable: class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter enabled: true 

Then in your organization:

 <?php namespace Foo\BarBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; /** * ... * @Gedmo\SoftDeleteable(fieldName="deletedAt") * @ORM\Entity */ class Foo { /** * @var \DateTime $deletedAt * * @ORM\Column(name="deleted_at", type="datetime", nullable=true) */ private $deletedAt; 

Then just delete objects like you, as a rule (the extension will take care of the rest):

  $em = $this->getDoctrine()->getManager(); $em->remove($entity); $em->flush(); 
+40
source share

I also needed another piece of the puzzle: Doctrine yaml config:

 XYBundle\Entity\Adresse: type: entity table: adresse gedmo: soft_deleteable: field_name: deleted_at time_aware: false id: id: type: integer generator: { strategy: AUTO } fields: ort: type: string length: 100 plz: type: string columnDefinition: varchar(255) NOT NULL DEFAULT '' deleted_at: type: datetime nullable: true 
+1
source share

All Articles