2014-04-10 1 views

답변

0

이름이 고유하면 아무런 문제가 없습니다.

namespace Yourapp\OneBundle\Controller; 

class OneController extends Controller 
{ 
    public function oneAction() 
    { 
     $otherControllerManager = $this->get('youappOtherbundle.the_manager'); 
    } 
} 

는 편집 : 좋아, 당신도 컨트롤러를 확장 할 수는 서비스와 같은 컨트롤러라고 나에게 보였다. 평상시처럼 필요한 서비스를 "전송하지"않는 이유는 무엇입니까? 당신의 services.yml 당신의 컨트롤러에서

OneController.controller.service: 
    class: Yourapp\OneBundle\Controller\OneController 
    arguments: ["@templating", "@router"] 

에서

:

public function __construct(EngineInterface $templating, UrlGeneratorInterface $router) 
{ 
    $this->templating = $templating; 
    $this->router = $router; 
} 
+0

씨야, 이것은 컨트롤러에서 수행 할 수 있습니다,하지만 난 내 컨트롤러를 정의로 내 컨트롤러 내 컨트롤러 클래스를 확장하고 있지 않다 서비스로서. – rohitrounak

+0

답변이 다른 방법으로 편집되었습니다. – Healkiss

+0

이 방법을 시도했지만 항상 __construct 인수가 null이됩니다. – rohitrounak

관련 문제