Replace $this->getDoctrine() and $this->dispatchMessage() calls in AbstractController with direct service use
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Doctrine\Persistence\ManagerRegistry;
final class SomeController extends AbstractController
{
+ public function __construct(
+ private ManagerRegistry $managerRegistry
+ ) {
+ }
+
public function run()
{
- $productRepository = $this->getDoctrine()->getRepository(Product::class);
+ $productRepository = $this->managerRegistry->getRepository(Product::class);
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony60\Rector\MethodCall\GetHelperControllerToServiceRector;
return RectorConfig::configure()
->withRules([
GetHelperControllerToServiceRector::class,
]);