简体   繁体   中英

getAll values from Doctrine entity (Symfony3)

I have this controller:

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);
    }

and this 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

When I try to get all records in table, I receive this error, but I can't understand what is wrong in my metadata:

Expected metadata for class AppBundle\\Entity\\ChangeLog to be defined in /vagrant/catalog/app/config/serializer/AppBundle/Entity.ChangeLog.yml

I DB my records look like this: 在此处输入图片说明

I think, that I need to do something with change_set, but I have no idea how to do that... Maybe you can help me... Update1

After some manipulation with metadata (edit) I receive this error:

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

I think that this error

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

is because you have two type

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM