-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected: 4.2.x
Description
Since v4.2.x, symfony shows a deprecation warning about not using the Symfony\Bundle\FrameworkBundle\Controller\AbstractController but Symfony\Bundle\FrameworkBundle\Controller\Controller. After changing all controllers to extend the abstract version, the test environment breaks when there is a non-shared service in use.
How to reproduce
Create a service and configure it as non-shared.
App\Service\Prismic\LinkResolverService:
# not shared because of function setFullResolve
shared: false
Inject the service in a controller:
<?php
namespace App\Controller;
use App\Service\Prismic\LinkResolverServiceInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class CareersController extends AbstractController
/**
*
* @var LinkResolverServiceInterface
*/
private $prismicLinkResolver;
public function __construct(LinkResolverServiceInterface $prismicLinkResolver)
{
}
Now, when calling the console
./bin/console --env-test
the following error is shown:
In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:
The service "App\Controller\CareersController" has a dependency on a non-existent service "App\Service\Prismic\LinkResolverService".
Additional context
When I have 2 controllers, one which doesn't inject LinkResolverServiceInterface and one that does. The error is also triggered if only the controller without the injection extends the AbstractController.