Gedmo loggable works but doesn't save username

I have a journal working on my entity, so when I make changes to the product field with annotation @Gedmo\Versioned, a new version is created. However, the only problem is that the field usernameremains NULL. There is an authenticated user since the update is performed in the Sonata Admin firewall.

<?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 looks like it is log_user_lookup_idxworking incorrectly, is there a specific configuration bit required for this?

+4
source share
1 answer

It looks like I lost a little configuration, adding the following to the main file app/config/config.yml, did the trick.

stof_doctrine_extensions:
    default_locale: en
    orm:
        default:
            loggable: true

< <22 > config:

gedmo.listener.loggable:
    class: Gedmo\Loggable\LoggableListener
    tags:
        - { name: doctrine.event_subscriber, connection: default }
    calls:
        - [ setAnnotationReader, [ "@annotation_reader" ] ]

, , , stof_doctrine_extensions.

, , .

+6

Source: https://habr.com/ru/post/1607686/


All Articles