我现在面临的问题与Symfony的2.x版的服务。当我尝试使用它的服务给我下面的错误Symfony的2.X服务引发异常
FatalErrorException: Error: Call to a member function has() on a non-object in C:\wamp\www\skerp8\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\Controller.php line 202
in C:\wamp\www\skerp8\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\Controller.php line 202
at ErrorHandler->handleFatalError() in C:\wamp\www\skerp8\vendor\symfony\symfony\src\Symfony\Component\Debug\ErrorHandler.php line 219
at ErrorHandler->handleFatal() in C:\wamp\www\skerp8\vendor\symfony\symfony\src\Symfony\Component\Debug\ErrorHandler.php line 0
at Controller->getDoctrine() in C:\wamp\www\skerp8\src\Skerp\ProductionBundle\Controller\RouteCardController.php line 3030
at RouteCardController->getRouteCardSummaryDetailsByRoutecardIdAction() in C:\wamp\www\skerp8\src\Skerp\InventoryBundle\Controller\BlockInventoryController.php line 467
at BlockInventoryController->updateAction() in C:\wamp\www\skerp8\app\bootstrap.php.cache line 2951
at ??call_user_func_array:{C:\wamp\www\skerp8\app\bootstrap.php.cache:2951}() in C:\wamp\www\skerp8\app\bootstrap.php.cache line 2951
at HttpKernel->handleRaw() in C:\wamp\www\skerp8\app\bootstrap.php.cache line 2923
at HttpKernel->handle() in C:\wamp\www\skerp8\app\bootstrap.php.cache line 3062
at ContainerAwareHttpKernel->handle() in C:\wamp\www\skerp8\app\bootstrap.php.cache line 2305
at Kernel->handle() in C:\wamp\www\skerp8\web\app_dev.php line 28
at ??{main}() in C:\wamp\www\skerp8\web\app_dev.php line 0
以下是我config.yml代码
services:
RouteCardControllerService:
class: Skerp\ProductionBundle\Controller\RouteCardController
arguments:
container: "@service_container"
我打电话BlockInventoryController.php上述控制器用下面的代码。
$routecardControllerService = $this->get('RouteCardControllerService');
$routecardControllerService->updateRouteCardSummaryReportDetailsByRoutecardIdAction($routecardid)
在RouteCardController.php文件
public function getRouteCardSummaryDetailsByRoutecardIdAction($routecardid){
//Do something and return array of data
}
public function updateRouteCardSummaryReportDetailsByRoutecardIdAction($routecardid) {
$routecardSummaryDetails = $this->getRouteCardSummaryDetailsByRoutecardIdAction($routecardid);
//Do Something...
}
为什么会抛出一个错误。我应该如何实现一项服务,以便我可以访问其他控制器中的控制器的方法。
你能否粘贴堆栈跟踪? –
好吧,我会加 – Prabhanjan
symfony日志中最后一个记录是什么ID? (dev.log或prod.log accordind你的环境) –