Symfony Gedmo可记录工作但不存储用户名

Symfony Gedmo可记录工作但不存储用户名,symfony,logging,gedmo-loggable,Symfony,Logging,Gedmo Loggable,我已经在我的实体上进行了日志记录,这样当我使用@Gedmo\Versioned注释更改产品字段时,就会创建一个新版本。但是唯一的问题是,用户名字段仍然是NULL。在Sonata Admin后端执行更新时,有一个经过身份验证的用户 <?php namespace MyApp\CmsBundle\Entity\Log; use Doctrine\ORM\Mapping as ORM; use Gedmo\Loggable\Entity\MappedSuperclass\AbstractLo

我已经在我的实体上进行了日志记录,这样当我使用
@Gedmo\Versioned
注释更改产品字段时,就会创建一个新版本。但是唯一的问题是,
用户名
字段仍然是
NULL
。在Sonata Admin后端执行更新时,有一个经过身份验证的用户

<?php

namespace MyApp\CmsBundle\Entity\Log;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Loggable\Entity\MappedSuperclass\AbstractLogEntry;
use Gedmo\Loggable\Entity\Repository\LogEntryRepository;

/**
 * @ORM\Entity(repositoryClass="Gedmo\Loggable\Entity\Repository\LogEntryRepository", readOnly=true)
 * @ORM\Table(
 *      name="log_product",
 *      indexes={
 *          @ORM\Index(name="log_class_lookup_idx", columns={"object_class"}),
 *          @ORM\Index(name="log_date_lookup_idx", columns={"logged_at"}),
 *          @ORM\Index(name="log_user_lookup_idx", columns={"username"}),
 *      }
 * )
 */
class ProductLog extends AbstractLogEntry
{

}

看来我缺少了一点配置,将以下内容添加到主
app/config/config.yml
文件中就成功了

stof_doctrine_extensions:
    default_locale: en
    orm:
        default:
            loggable: true
我最初在bundle的
services.yml
config:

gedmo.listener.loggable:
    class: Gedmo\Loggable\LoggableListener
    tags:
        - { name: doctrine.event_subscriber, connection: default }
    calls:
        - [ setAnnotationReader, [ "@annotation_reader" ] ]
这成功地跟踪了被修改的实体,但没有跟踪用户,此后我删除了此配置,日志记录只需使用
stof_doctor_extensions
config设置即可


如果您的代码库中有这两个字段,则所有内容都将记录两次。

您是否配置了要记录的
用户名
字段?产品上没有
用户名
属性。它通过查找来获取用户对象。我只在代码中看到索引,这会在数据库表中创建索引,但不会配置字段的记录方式,请参见。您的反馈对我很有用。每次更改我都记录了两次。数据库中充满了重复项。谢谢