protected function doDelete(Entity $entity, $deleteCascade)
{
$result = $this->shouldExecuteEvents($entity, 'before', 'delete');
if (!$result) {
return static::DELETION_FAILED_EVENT;
}
$id = $entity->get('id');
if ($deleteCascade) {
$this->deleteChildren($id, $deleteCascade);
} elseif ($this->hasChildren($id)) {
return static::DELETION_FAILED_STILL_REFERENCED;
}
$query = $this->database->createQueryBuilder();
$query->update('`' . $this->definition->getTable() . '`')->set('deleted_at', 'UTC_TIMESTAMP()')->where('id = ?')->setParameter(0, $id);
$query->execute();
$this->shouldExecuteEvents($entity, 'after', 'delete');
return static::DELETION_SUCCESS;
}