0
次のサービスファイルから実行するためにdoctrineを設定する際に問題があります。symfonyとDoctrineを使用してnull 500にhas()関数を呼び出す
<?php
// src/AppBundle/Services/SuperusersService.php
namespace AppBundle\Services;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Doctrine\ORM\EntityManager;
class SuperusersService extends Controller
{
public function sayHello()
{
$em = $this->getDoctrine()->getManager();
// Query here
}
}
上記を実行すると、次のエラーメッセージが表示されます。ヌル500内部サーバーエラーのメンバ関数への
コールがある() - FatalThrowableError
私は、次のコントローラファイルからファイルを呼び出します。
# Learn more about services, parameters and containers at
# http://symfony.com/doc/current/service_container.html
parameters:
# parameter_name: value
services:
# service_name:
# class: AppBundle\Directory\ClassName
# arguments: ["@another_service_name", "plain_value", "%parameter_name%"]
app.superusers.services:
class: AppBundle\Services\SuperusersService
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class LoginController extends Controller
{
/**
* @Route("/login")
*/
public function indexAction(Request $request)
{
if(!empty($_POST)){
////
// If for submitted attempt to log the user in.
////
$superusersService = $this->get('app.superusers.services');
$superusersService->sayHello();
}
$name = "Login";
return $this->render('login/login.html.php',
array());
}
}
サービスファイルは今、私は他の質問で周りを見て撮影してきたが、まだのように私は、上記を解決することができません。私はそれがファイルの設定と関係があると思うが、私は何がわからない。あなたが道あなたを、あなたの依存関係を注入する必要が を:コントローラは、サービスコンテナ属性は、したがって、あなたは、もはや
$this->get('service_name')
溶液でサービスを受けることができませんもはや存在しないと宣言されている