我的老闆爲softdelete過濾器安裝了這個軟件包,但documentation已經超出了稀疏。我如何在我的刪除查詢中使用它?StofDoctrineExtensionsBundle softdelete - 我如何使用它?
8
A
回答
38
在你的配置啓用它:
stof_doctrine_extensions:
orm:
default:
...
softdeleteable: true
doctrine:
...
orm:
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
在實體
然後:
<?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;
然後,只需刪除就像你通常會(在擴展需要完成剩餘的工作)實體:
$em = $this->getDoctrine()->getManager();
$em->remove($entity);
$em->flush();
0
我還需要另一個拼圖部分:教條yaml配置:
ANWISBundle\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. 使用SoftDelete的MethodNotAllowedHttpException
- 2. 如何級聯SoftDelete?
- 3. Symfony2:EasyAdminbundle + StofDoctrineExtensionsBundle + VichUploaderBundle
- 4. StofDoctrineExtensionsBundle可上傳
- 5. Laravel得到softdelete
- 6. nhibernate softdelete覆蓋
- 7. gedmo_translatable vs gedmo_translator - StofDoctrineExtensionsBundle - Symfony2
- 8. 如何在rails中實現softdelete
- 9. 的Symfony2:暫時禁用softdelete
- 10. 我會如何使用它?
- 11. WhiteRaccoon我如何使用它?
- 12. CakeEmail - 我如何使用它?
- 13. 如何使用symfony3,doctrine2和stofDoctrineExtensionsBundle獲取Gedmo Tree元素的路徑
- 14. 抽象類或SoftDelete接口
- 15. 通過StofDoctrineExtensionsBundle包含DoctrineExtensions是否安全?
- 16. scrollspy:我如何才能使用它?
- 17. JDBC - prepareStatement - 我應該如何使用它?
- 18. PHP我該如何使用它?
- 19. 我如何找回它使用GROUPBY列
- 20. 資金格式 - 我如何使用它?
- 21. 怎麼做?我如何使用它?
- 22. JAVA,System.exit()?我如何使用它?
- 23. MySQL異步 - 我該如何使用它?
- 24. 什麼是args,我如何使用它?
- 25. Subversion和我如何使用它?
- 26. 什麼是ipc?我如何使用它?
- 27. Laravel cartalyst sentinel - Softdelete and restore a user
- 28. JOIN如何工作,我如何正確使用它,我甚至需要它嗎?
- 29. $ softDelete在模型測試中的問題
- 30. ZF2,Doctrine2,Gedmo - SoftDelete JTI實體與協會
該文檔不會超越稀疏。 StofDoctrineExtensionsBundle只是Symfony的[Doctrine Extenssions](https://github.com/l3pp4rd/DoctrineExtensions)的集成。因此,請查看[softdeleteable documentation](https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/softdeleteable.md) –