I get error on Adding custom action in symfony Warning: array_merge(): Expected parameter 2 to be an array, null given

I have a dating website programmed with symfony. I want to add a function in easyadmin to be able to delete a user and her/his messages and posts. In UserCrudController I followed the instruction in symfony website and write a custom action. But I get an error

Warning: array_merge(): Expected parameter 2 to be an array, null given

public function configureActions(Actions $actions): Actions
    {
        // this action executes the 'renderInvoice()' method of the current CRUD controller
        $delUserAction = Action::new('deleteUser', 'Delete user completely')
            ->linkToRoute('delete_user', function (User $user){
                $id = $user->getId();
                $res = $this->getDoctrine()->getRepository(User::class)->find($id);
                if ($res) {
                    $em = $this->getDoctrine()->getManager();
                    $em->remove($res);
                    $em->flush();
                }
                $res = $this->getDoctrine()->getRepository(Message::class)->remove_all_message($id);
                $res = $this->getDoctrine()->getRepository(Beziehungen::class)->remove_all_relations($id);
                $res = $this->getDoctrine()->getRepository(Album::class)->remove_album_of_user($id);
                $res = $this->getDoctrine()->getRepository(Blog::class)->remove_blog_of_user($id);
                $res = $this->getDoctrine()->getRepository(Comment::class)->remove_comments_of_user($id);
                $res = $this->getDoctrine()->getRepository(Subcomment::class)->remove_subcomments_of_user($id);
                $res = $this->getDoctrine()->getRepository(Like::class)->remove_likes_of_user($id);
            });

        return $actions
            // ...
            ->add(Crud::PAGE_INDEX, $delUserAction)
            ;
    } 

Can you please help me?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *