I'm trying migrate to symfony 3.3 and use new feature autowire
/autoconfigure
services:
So in services.yml i have:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
# makes classes in src/AppBundle available to be used as services
AppBundle\:
resource: '../../src/AppBundle/*'
# you can exclude directories or files
# but if a service is unused, it's removed anyway
exclude: '../../src/AppBundle/{Entity,Controller,DQL,Form/DataTransformer,Repository}'
i declare my twig extension as:
AppBundle\Twig\ImageExtension:
arguments:
$env: "%kernel.environment%"
and constructor for this service:
public function __construct(TokenStorage $token, UserRepository $userRepository, RedisCacheService $cache, string $env)
{
$this->env = $env;
$this->user = $token->getToken() ? $token->getToken()->getUser() : false;
$this->userRepository = $userRepository;
$this->cache = $cache;
}
seems that all is ok, but i'm getting this error:
(1/1) AutowiringFailedException
Cannot autowire service "AppBundle\Twig\ImageExtension": argument "$env" of method "__construct()" must have a type-hint or be given a value explicitly.
and have no idea how to fix it.
env
argument, he talks about his configuration that does not work. Based on the official documentation about manually wiring, his configuration looks correct. @Ensoll : Are you sure you update your Symfony dependencies up to 3.3+ ? – Rally3
instead of$env
. Or used empty quotes for the others 3 services.argument: ['', '', '', '%kernel.environment%]
– Rally