2016-09-22 14 views
-2

symfonyを使い始めるとサービスに問題が発生しました。symfonyサービスの実行に問題があります

... \アプリ\ CONFIG \ services.yml

app.pdf.service: 
    class: AppBundle\Service\PdfService 
    arguments: [format, orientation]] 

... \ SRC \ AppBundle \サービス\ PdfService.php

namespace AppBundle\Service; 

class PdfService 
{ 

    private $format; 
    private $orientation; 

    public function __construct($format, $orientation) 
    { 
     $this->format = $format; 
     $this->orientation = $orientation; 
    } 

} 

そして今、私は、サービスを利用しようwith:

$this->container->get('app.pdf.service'); 

私は何かを忘れましたか? $ this-> container-> get(ist working、whiteoctober/tcpdf-bundleからtcpdf/serviceを呼び出したので、このサービスを拡張します。 s00n N00N

+0

エラーが表示されましたか? – mblaettermann

+0

'引数:[format、orientation]] - >余分な括弧'] '?? – yceruto

+0

thxですが、コピー&ペーストの間違いでした。私のIDEでは、2番目のブラケットはセットされていませんでした。 – n00n

答えて

0

はしてみてください、その形式や向きがよく、あなたのパラメータで定義されていると想定します

app.pdf.service: 
    class: AppBundle\Service\PdfService 
    arguments: ["%format%", "%orientation%"] 

"ハードコードされた" の定義の例を:

app.pdf.service: 
    class: AppBundle\Service\PdfService 
    arguments: ["a4", "landscape"] 

詳細については、公式ドキュメントを確認してください: https://symfony.com/doc/current/components/dependency_injection.html#setting-up-the-container-with-configuration-files

+0

いいえ、動作していない可能性があります。サービスが利用可能になる前に設定する必要があります。コンテナ内でサービスが利用できないようです。 – n00n

関連する問題