1

我试图让 DoctrineExtensions 结合 XML 为我的 Doctrine 2 工作。

看起来我很接近了,但每次我尝试加载一个实体时,我的网站都会因致命错误而死:

Class must be annoted with Loggable annotation in order to track versioned fields 
in class

我的 XML 如下所示:

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
    <entity name="Base\Activity\Organisation" table="activity_organisation">
        <id name="id" type="integer" column="id">
            <generator strategy="IDENTITY"/>
        </id>
        <field name="name" type="string" column="name" length="255" precision="0" scale="0">
            <gedmo:versioned/>
        </field>
    </entity>
</doctrine-mapping>`

现在的问题是:如何使用 Loggable 注释来注释我的类。

4

1 回答 1

1

我忘记了xml的一部分。我不得不添加以下内容:

<gedmo:loggable log-entry-class="Log\Location"/>

其中 log-entry-class 是您要用于记录的类。现在完成xml:

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
    <entity name="Base\Activity\Organisation" table="activity_organisation">
        <gedmo:loggable log-entry-class="Log\Location"/>
        <id name="id" type="integer" column="id">
            <generator strategy="IDENTITY"/>
        </id>
        <field name="name" type="string" column="name" length="255" precision="0" scale="0">
            <gedmo:versioned/>
        </field>
    </entity>
</doctrine-mapping>
于 2012-11-15T15:27:08.800 回答