Skip to content

Service defaults not working for factories #22143

@curry684

Description

@curry684
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version dev-master

Given the new features with anonymous services and service defaults, I was assuming the following syntax would work:

services:
    _defaults:
        factory:        [ "@doctrine", getRepository ]

    MyProject\UserRepository:
        arguments:      [ "AppBundle:User" ]

This errors with: "Please add the class to service "_defaults" even if it is constructed by a factory since we might need to add method calls based on compile-time checks."

Changing the defaults to:

    _defaults:
        class:          Doctrine\ORM\EntityRepository
        factory:        [ "@doctrine", getRepository ]

Appears to work at first, but doesn't, as this actually causes a service called _defaults to be created, and the other services in the file to ignore the defaults altogether.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions