2016-04-22 13 views
1

$リクエスト引数に必要な値以下symfonyの例外:私はこのようになりますLoginActionの持つ

Controller "SystemBundle\Controller\SystemController::loginAction()" requires that you provide a value for the "$request" argument (because there is no default value or because there is a non optional argument after this one).

は、ルーティングです:

system_login: 
path: /login 
defaults: { _controller: SystemBundle:System:login} 

とフォーム:

<form method="POST" id="lgn" action="{{ path('system_login') }}"> 
     <span class="fa fa-times close" onclick="lgn()" ></span><br /> 
     <span>Login:</span> 
     <input type="email" placeholder="Email" required="required" name="umail" /> 
     <input type="password" placeholder="Password" required="required" name="upass" /> 
     <button type="submit">login</button> 
    </form> 

私はあなたのコントローラで問題を考える...

+3

'Symfony \ Component \ HttpFoundation \ Request'クラスを正しくインポートしましたか? –

答えて

3

を助けてください。それはOPのための正しい解決策だったので、私はここにこの答えを追加しているが、彼は間違った答えを選んだ

use Symfony\Component\HttpFoundation\Request; 

class FooController extends Controller 
{ 

    public function loginAction(Request $request) 
    { 

     if($request->getMethod() == 'POST') 
     { 
      $mail = $request->request->get('umail'); 
      $pass = $request->request->get('upass'); 
      $em = $this->getDoctrine()->getManager(); 
      $rep = $em->getRepository('SystemBundle:User'); 

      $user = $rep->findOneBy(array("email"=>$mail,"pass"=>$pass)); 
      if($user) 
      { 
      $id = $user->getId(); 
      $type = $user->getType(); 

      return $this->render('@System/Pages/admin/index.html.twig'); 
      } 
     } 
    } 

}

+1

ありがとう、使用声明でWebkitバンドルを追加しました! –

0

:これを試してみてください。 Kuba Bireckiにこの答えに対する彼のコメントを捧げます。

symfonyは、利用可能なautowire-able引数型のリストと一致しないため、$ request引数をautowireに失敗しています。これは、リクエストタイプヒントを追加したときにIDEが間違ったクラスのuseステートメントを追加したためです。

useの文がSymfony\Component\HttpFoundation\Requestであることを確認してください。

関連する問題