0

在我使用 Symfony 4.2 和 API 平台开发的应用程序中,
我安装了DoctrineExtensions 包以使用 Loggable 扩展,
并按照Symfony 文档Loggable 扩展中的说明进行操作。

当我只使用一个 EntityManager 时,一切正常。
但我想将 LogEntry 实体表移动到另一个数据库。
因此,我创建了第二个 EntityManager,如Symfony 文档中所述。

之后,我在我的应用程序中修改了一个具有注释的实体,@Gedmo\Loggable
我收到了这个错误:
The class 'Gedmo\Loggable\Entity\LogEntry' was not found in the chain configured namespaces 'App\Entity'.

我的config/packages/doctrine.yaml文件:

parameters:
    env(DATABASE_URL): ''

doctrine:
    dbal:
        connections:
            default:
                driver: 'pdo_mysql'
                server_version: '%env(resolve:SERVER_VERSION)%'
                charset: utf8mb4
                default_table_options:
                    charset: utf8mb4
                    collate: utf8mb4_unicode_ci
                url: '%env(resolve:DATABASE_URL)%'
            log:
                driver: 'pdo_mysql'
                server_version: '%env(resolve:SERVER_VERSION)%'
                charset: utf8mb4
                default_table_options:
                    charset: utf8mb4
                    collate: utf8mb4_unicode_ci
                url: '%env(resolve:LOG_DATABASE_URL)%'
    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        entity_managers:
            default:
                naming_strategy: doctrine.orm.naming_strategy.underscore
                mappings:
                    App:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity'
                        prefix: 'App\Entity'
            log:
                naming_strategy: doctrine.orm.naming_strategy.underscore
                connection: log
                mappings:
                    gedmo_loggable:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity'
                        prefix: 'Gedmo\Loggable\Entity'
                        alias: GedmoLoggable

我想观看的实体示例:

<?php
namespace App\Entity;

...
use Gedmo\Mapping\Annotation as Gedmo;
...

/**
 * @ApiResource
 * @Gedmo\Loggable
 * @ORM\Table(name="patients")
 */
class Patient
{
    /**
     * @ORM\Id
     * @ORM\Column(type="guid", unique=true)
     * @ORM\GeneratedValue(strategy="UUID")
     * @Assert\Uuid
     */
    private $id;

    /**
     * @ORM\Column(length=50)
     * @Assert\NotBlank()
     * @Assert\Length(max=50)
     * @Gedmo\Versioned
     */
    public $familyName;

    /**
     * @ORM\Column(length=50)
     * @Assert\NotBlank()
     * @Assert\Length(max=50)
     * @Gedmo\Versioned
     */
    public $firstName;

    ...
}

我试图添加和删除一些属性,doctrine.yaml但我总是得到同样的错误......

谢谢你的时间。

4

0 回答 0