2016-10-27 7 views
3

symfony3에서 trans 메소드를 재정의하는 방법을 알아야합니다. 번역기 클래스가 symfony3에서 작동하지 않음

는 symfony2 프로젝트에서 우리는 우리가 symfony3를 사용하기 시작 번역자 클래스

parameters: 
    translator.class: Acme\HelloBundle\Translation\Translator 

에 대한 매개 변수를 무시하고 동일한 접근하지만 불행히도 parameter was removed 및 클래스 경로가 서비스에 직접 기록을 적용하려고하는 데 사용됩니다.

답변

1

기존 정의를 재정의 할 수 있습니다 (예 : Decorator pattern 적용). 이런 장식은 in the doc으로 묘사 된 Symfony의 Dependency Injection Container에서 지원됩니다.

services: 
    app.mailer: 
     class: AppBundle\Mailer 

    # this replaces the old app.mailer definition with the new one, the 
    # old definition is lost 
    app.mailer: 
     class: AppBundle\DecoratingMailer 

과 : 예를 들어

services: 
    # ... 

    app.decorating_mailer: 
     class:  AppBundle\DecoratingMailer 
     decorates: app.mailer 
     arguments: ['@app.decorating_mailer.inner'] 
     public: false 

희망이 도움

+0

덕분에 너무 많은,하지만 불행히도 내가 잘못 인수 예외를 얻을. ** 잡아낼 치명적인 오류 : 심포니 \ 번들 \ FrameworkBundle \ 번역 \ 번역기에 전달 된 인수 1 : __ 은 장식이를 구조() 인터페이스 심포니 \ 구성 요소 \ 의존성 주입 \ ContainerInterface를 구현해야합니다, 아무것도 주어지지 **하지합니다 원래의 서비스에서와 같은 주장? 또는 원래 번역기 수업을 연장한다는 사실을 알고 새로운 언어로 다시 전달해야합니다. 또한 시도했지만 yaml XML 스키마를 매핑 할 수 없습니다. –

+0

같은 문제가 있습니다. 그것을 해결 했습니까? @ 게바트 모하메드 –

관련 문제