我尝试在我的应用程序中使用softdelete,但它不起作用。当我删除一个实体时,它也会从数据库中删除。
我安装了" stof / doctrine-extensions-bundle":" 1.2。* @ dev" 并将其添加到内核中。
我的配置:
stof_doctrine_extensions:
orm:
default:
...
softdeleteable: true
doctrine:
...
orm:
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
我的YML定义:
...\Entity\Person:
type: entity
table: person
id:
id:
...
fields:
salutation:
type: string
length: 255
...
deletedAt:
type: datetime
nullable: true
我的实体:
<?php
namespace ...\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* Person
* @Gedmo\SoftDeleteable(fieldName="deletedAt")
*/
class Person
{
...
/**
* @var \DateTime
*/
private $deletedAt;
...
/**
* Set deletedAt
*
* @param \DateTime $deletedAt
* @return NaturalPerson
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get deletedAt
*
* @return \DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
}