Reputation: 15
I'm using symfony version 3.4.8. The configuration works in symfony 3.3, but in symfony 3.4 I get:
Cannot autowire service "ProblemBundle\EntityManager\ProblemManager": argument "$paginator" of metho
d "__construct()" references interface "Knp\Component\Pager\PaginatorInterface" but no such service
exists. Did you create a class that implements this interface?
ProblemManager.php
public function (PaginatorInterface $page){}
app/config/services.yml
# Learn more about services, parameters and containers at
# https://symfony.com/doc/current/service_container.html
parameters:
#parameter_name: value
services:
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
autowire: true
# automatically registers your services as commands, event subscribers, etc.
autoconfigure: true
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: true
# makes classes in src/AppBundle available to be used as services
# this creates a service per class whose id is the fully-qualified class name
# add more services, or override services that need manual wiring
# AppBundle\Service\ExampleService:
# arguments:
# $someArgument: 'some_value'
UserBundle\Controller\:
resource: '../../src/UserBundle/Controller'
public: true
autowire: true
tags: ['controller.service_arguments']
UserBundle\EntityManager\UserManager:
autowire: true
ProblemBundle\EntityManager\ProblemManager:
autowire: true
public: true
How can I configure autowiring for all (including third party bundle)?
Upvotes: 0
Views: 960
Reputation: 17576
Instruct the Dependency Injection component which implementation would you like to use, for instance:
Knp\Component\Pager\PaginatorInterface:
public: true
alias: Your\Solid\Implementation
Should you want to use another implementation, it's a matter of changing this single configuration line.
Upvotes: 1
Reputation: 875
You can still inject Non-Autowireable
arguments by service tags, in your case it would be
ProblemBundle\EntityManager\ProblemManager:
autowire: true
public: true
arguments:
$page: "@knp_paginator.injectable"
see: https://github.com/KnpLabs/KnpPaginatorBundle
Upvotes: 0