I have got logging working on my entity so that when I make a change to a product field with the @Gedmo\Versioned
annotation a new version is created. However the only problem is that the username
field remains NULL
. There is an authenticated user as the update is performed in Sonata Admin backend.
<?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
{
}
So it would appear the log_user_lookup_idx
isn't working correctly, is there a particular bit of config I require for this?
It appears I was missing a bit of config, adding the following to the main
app/config/config.yml
file did the trick.I did originally have this in my bundles'
services.yml
config:This managed to track the entity being modified but not the user, I have since removed this config and the logging remains to work with just the
stof_doctrine_extensions
config setting.If you have both in your code base then everything will be logged twice I found.