loggable不会将任何内容记录到数据库

时间:2017-01-17 08:50:30

标签: symfony gedmo-loggable

在我的Symfony项目中,我们想要使用Gedmo / Loggable插件。

不幸的是我没有为这个插件找到明确的文档。 仅适用于完整的Stof \ DoctrineExtensionsBundle \ StofDoctrineExtensionsBundle() https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html

我有" \ text_log_entries"我的数据库中的表。但是,当我在记录的实体上更改某些内容时,没有任何声明。

config.yml:

orm:
    auto_generate_proxy_classes: true #"%kernel.debug%"
    naming_strategy: doctrine.orm.naming_strategy.underscore
    auto_mapping: true


    mappings:
      gedmo_loggable:
          type: annotation
          prefix: Gedmo\Loggable\Entity
          dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
          alias: GedmoLoggable # (optional) it will default to the name set for the mappingmapping
          is_bundle: false

实体

/**
 * company
 *
 * @ORM\Table(name="company")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\companyRepository")
 * @ORM\HasLifecycleCallbacks()
 * 
 * @Gedmo\Loggable
 */
class company 
{

    /**
     * @var string 
     * @Gedmo\Versioned
     */
    private $companyName;
}

有人能说我,我的错误在哪里吗?

1 个答案:

答案 0 :(得分:1)

我找到了原因。

我没有将服务注入services.yml

  gedmo.listener.loggable:
        class: Gedmo\Loggable\LoggableListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }

在教程中没有找到这一步。现在它工作正常。