簡體   English   中英

從Doctrine實體(Symfony3)的getAll值

[英]getAll values from Doctrine entity (Symfony3)

我有這個控制器:

public function getLogAction()
    {
        $result = $this->getDoctrine()->getRepository(ChangeLog::class)->findAll();
        if ($result === NULL) {
            return new View("Log not found", Response::HTTP_NOT_FOUND);
        }
        return new View($result,Response::HTTP_OK);
    }

和這個Entity.ChangeLog.yml:

AppBundle\Entity\ChangeLog:
    exclusion_policy: ALL
    properties:
        id:
            type: integer
        date:
            access_type: public_method
            expose: true
            type: datetime
        user:
            type: AppBundle\Entity\Category
            access_type: public_method
            expose: true
            type: string
        entityName:
            expose: true
            type: string
        entityId:
            type: int
            expose: true
        action:
            type: string
            expose: true
        changeSet:
            type: array
            expose: true
        description:
            type: string
            expose: true

當我嘗試獲取表中的所有記錄時,收到此錯誤,但我不明白我的元數據有什么問題:

AppBundle \\ Entity \\ ChangeLog類的預期元數據將在/vagrant/catalog/app/config/serializer/AppBundle/Entity.ChangeLog.yml中定義

我DB我的記錄如下所示: 在此處輸入圖片說明

我認為我需要對change_set做些事情,但是我不知道該怎么做...也許您可以幫我... Update1

經過對元數據(編輯)的一些操作后,我收到此錯誤:

警告:ReflectionProperty :: getValue()期望參數1為對象,給定字符串

我認為這個錯誤

Warning: ReflectionProperty::getValue() expects parameter 1 to be object, string given

是因為你有兩種類型

user:
    type: AppBundle\Entity\Category
    access_type: public_method
    expose: true
    type: string

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM