my old solution after the previous answer from @Ken Hannel:
Edit: /vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php
Replace the walkDeleteClause function as follows:
public function walkDeleteClause(AST\DeleteClause $deleteClause) { $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName); $tableName = $class->getTableName(); $sql = 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform); $this->setSQLTableAlias($tableName, $tableName, $deleteClause->aliasIdentificationVariable); $this->rootAliases[] = $deleteClause->aliasIdentificationVariable; //check if SoftDeleteableListener is attached foreach ($this->em->getEventManager()->getListeners() as $eventName => $listeners) { foreach ($listeners as $listener) { if ($listener instanceof \Gedmo\SoftDeleteable\SoftDeleteableListener) { $date = date('Ymd H:i:s'); $sql = 'UPDATE ' . $this->quoteStrategy->getTableName($class, $this->platform) . " SET deletedAt = ' " . $date . " ' "; } } } return $sql; }
but actually, but I think Ken Hannelβs method is more professional and conforms to the standard.
source share