I am trying to upgrade to symfony 3.3 and use the new autowire/ autoconfigureservices function :
So in services.yml I have:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
AppBundle\:
resource: '../../src/AppBundle/*'
exclude: '../../src/AppBundle/{Entity,Controller,DQL,Form/DataTransformer,Repository}'
I declare my branch 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;
}
Everything seems to be in order, but I get 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 don’t know how to fix it.
source
share