0

私は Symfony 2 を使用しており、いくつかの計算を処理するカスタム サービス コンテナーを作成しようとしています。

私のservices.yml

services:
    my_calculator:
        class:        my_app\HomeBundle\Services\CalculatorService
        arguments:    [doctrine]

CalculatorService は以下のとおりです。

<?php 
namespace my_app\HomeBundle\Services;

use my_app\CategoryBundle\Entity;

class CalculatorService
{
    protected $doctrine;

    public function __construct($doctrine)
    {
        $this->doctrine = $doctrine;
    }

    public function calculate($data=array())
    {
        if(!empty($data))
        {
        }
    }
}

私のコントローラー機能

public function calculateAction()
{
    $request = $this->get('request');

    $calculator=$this->get('my_calculator');
 }

教義オブジェクトがコンストラクターに到達しないという私の問題

私はしようとしましarguments: [@doctrine]arguments: [@doctrine.orm.entity_manager]

@しかし、ymlファイルに書き込むと解析エラーが発生します

助けてください

4

1 に答える 1