我的bundle扩展类(symfony 3)有什么问题? [关闭]

Seems your controller is not defined as a service, so you can use the service in the controller as:

/**
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function sendAction(Request $request)
    {
        $notification = new Notification();
        $user = $this->get('security.token_storage')->getToken()->getUser();
        $notification->setBody($request->request->get('subject'), $user->getUsername());
        $notification->setSubject($request->request->get('body'));
        try {
            $this->get('emailsender')->send($notification);
        } catch (\Exception $ex) {
            $this->render('MailerBundle:Email:error.html.twig', [
                'message' => $ex->getMessage()
            ]);
        }
        $this->render('MailerBundle:Email:success.html.twig');
    }

Hope this help