Skip to content

Circular Reference When Using @service_container on autowiring mode #17252

@ad3n

Description

@ad3n
services:
    app.menu:
        class: AppBundle\Menu\Builder
        autowire: true
#        arguments:
#            - '@router'
#            - '@service_container'

Before i comment the arguments, the service is work. After that i try to use auto wiring mode and got error

[Symfony\Component\DependencyInjection\Exception\RuntimeException]                                                          
  Unable to autowire argument of type "Symfony\Component\DependencyInjection\ContainerInterface" for the service "app.menu".

And then i try to add auto wire type

services:
    app.menu:
        class: AppBundle\Menu\Builder
        autowire: true
        autowiring_types: Symfony\Component\DependencyInjection\ContainerInterface
#        arguments:
#            - '@router'
#            - '@service_container'

and i got another error

[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException]  
  Circular reference detected for service "app.menu", path: "app.menu -> app.menu". 

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