首页 文章

类型错误:函数参数太少

提问于
浏览
3

services.yml 位于src / EliteFifa / MatchBundle / Resources / services.yml

parameters:
    # repositories
    match_repository.class:             EliteFifa\MatchBundle\Repository\MatchRepository
    match_repository.factory_argument:  'MatchBundle:Match'

# services
match_service.class:                EliteFifa\MatchBundle\Service\MatchService

services:
    # services
    elite_fifa.match_service:
        class: %match_service.class%
        arguments:
          - '@elite_fifa.match_repository'
          - '@=service("form.factory")'
          - '@elite_fifa.standing_service'

.

class MatchService
{
    /**
     * @var MatchRepository
     */
    private $matchRepository;

    /**
     * @var FormFactory
     */
    private $formFactory;

    /**
     * @var StandingService
     */
    private $standingService;

    /**
     * @param MatchRepository $matchRepository
     * @param FormFactory $formFactory
     * @parma StandingService $standingService
     */
    public function __construct(
        MatchRepository $matchRepository,
        FormFactory $formFactory,
        StandingService $standingService)
    {
        $this->matchRepository = $matchRepository;
        $this->formFactory = $formFactory;
        $this->standingService = $standingService;
    }

突然间Symfony已经停止识别其他参数,我添加了 - '@elite_fifa.standing_servicee' 但是得到以下错误:

类型错误:函数EliteFifa \ MatchBundle \ Service \ Mat chService :: __ construct()的参数太少,2在1128行传入/ home / owner / Desktop / Workspace / EFL / var /cache/dev/appDevDebugProjectContainer.php正好3预期

我已经尝试清除缓存,但这也不起作用 .

1 回答

  • 0

    尝试将 '@=service("form.factory")' 替换为 '@form.factory'

    parameters:
        # repositories
        match_repository.class:             EliteFifa\MatchBundle\Repository\MatchRepository
        match_repository.factory_argument:  'MatchBundle:Match'
    
    # services
    match_service.class:                EliteFifa\MatchBundle\Service\MatchService
    
    services:
        # services
        elite_fifa.match_service:
            class: %match_service.class%
            arguments:
              - '@elite_fifa.match_repository'
              - '@form.factory'
              - '@elite_fifa.standing_service'
    

相关问题