M
M
Maxim Lagoysky2019-10-02 13:54:58
symfony
Maxim Lagoysky, 2019-10-02 13:54:58

Why doesn't the FOSRestBundle annotation work?

There is a route that must give anything. For example

/**
     * Lists all Users
     * @Rest\Get("/users")
     * @Rest\View(serializerEnableMaxDepthChecks=true)
     * @param EntityManagerInterface $em
     * @return Response
     */
    public function getUsers(EntityManagerInterface $em, SerializerInterface $serializer)
    {
        $users = $em->getRepository(User::class)->findAll();
//        $users = $serializer->serialize($users, 'json', SerializationContext::create()->enableMaxDepthChecks());
        $view = $this->view($users)->setData($users);
        return $this->handleView($view);
    }

the problem is that due to the connections / large depth of the object, it crashes with an error
ContextStack visiting not working well

In essence, I put @MaxDepth(1) on the connection, wrote @Rest\View(serializerEnableMaxDepthChecks=true) in the annotation in the control, but it doesn’t help, and if you manually serialize everything is fine. Why might an annotation not work?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question