Skip to content

Commit 1d01c14

Browse files
nuryagdymAkenRoberts
authored andcommitted
added SoftDeleteable configuration example
1 parent e55a672 commit 1d01c14

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

doc/symfony4.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,14 @@ services:
170170
- { name: doctrine.event_subscriber, connection: default }
171171
calls:
172172
- [ setAnnotationReader, [ "@annotation_reader" ] ]
173-
173+
174+
gedmo.listener.softdeleteable:
175+
class: Gedmo\SoftDeleteable\SoftDeleteableListener
176+
tags:
177+
- { name: doctrine.event_subscriber, connection: default }
178+
calls:
179+
- [ setAnnotationReader, [ "@annotation_reader" ] ]
180+
174181
Gedmo\Loggable\LoggableListener:
175182
tags:
176183
- { name: doctrine.event_subscriber, connection: default }
@@ -282,6 +289,7 @@ use Doctrine\ORM\Mapping as ORM; // doctrine orm annotations
282289

283290
/**
284291
* @ORM\Entity
292+
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
285293
*/
286294
class BlogPost
287295
{
@@ -309,7 +317,12 @@ class BlogPost
309317
* @Gedmo\Timestampable(on="update")
310318
*/
311319
private $updated;
312-
320+
321+
/**
322+
* @ORM\Column(type="datetime", nullable=true)
323+
*/
324+
private $deletedAt;
325+
313326
public function getId()
314327
{
315328
return $this->id;
@@ -334,6 +347,16 @@ class BlogPost
334347
{
335348
return $this->updated;
336349
}
350+
351+
public function getDeletedAt(): ?Datetime
352+
{
353+
return $this->deletedAt;
354+
}
355+
356+
public function setDeletedAt(?Datetime $deletedAt): void
357+
{
358+
$this->deletedAt = $deletedAt;
359+
}
337360
}
338361
```
339362

0 commit comments

Comments
 (0)