Search code examples
symfonydoctrine-ormdoctrinesymfony7

Symfony 7.1 - Doctrine 2.13 automapping feature deprecation


I am developing a project in Symfony 7.1 and since the last update, I have encountered a small problem with the following deprecation:

Since doctrine/doctrine-bundle 2.13: Enabling the controller resolver automapping feature has been deprecated. Symfony Mapped Route Parameters should be used as replacement.

Digging a bit into the Symfony docs, I found an article that talks about it and offers a solution to correct the deprecation: https://symfony.com/blog/new-in-symfony-7-1-mapped-route-parameters

With this help, I reviewed all of my controllers to make the necessary corrections but the deprecation is still there...

I reread my code 3 times, I have trouble understanding why the deprecation is still there.

Some examples of corrections I made :

 #[Route('/change-password/update/{id}', name: 'change_password_update_user', methods: ['POST'])]
    public function updatePassword(
        #[MapEntity(id: 'id')] User $user,
        UserService                 $userService,
        Request                     $request,
        TranslatorInterface         $translator
    ): JsonResponse
#[Route('/ajax/send-demo-mail/{id}', name: 'send_demo_mail', methods: ['GET'])]
    public function sendDemoMail(
        #[MapEntity(id: 'id')] Mail $mail,
        MailService                 $mailService,
        OptionSystemService         $optionSystemService,
        TranslatorInterface         $translator
    ): JsonResponse
 #[Route('/ajax/update-disabled/{id}', name: 'update_disabled', methods: ['PUT'])]
    public function updateDisabled(
        #[MapEntity(id: 'id')] Tag $tag,
        TagService                 $tagService,
        TranslatorInterface        $translator,
        Request                    $request
    ): JsonResponse

Did I misunderstand something?

Is there a trick to know the exact place that triggers the depreciation?

Unfortunately, the message I have is too vague and does not indicate the place that is causing the problem.

    Since doctrine/doctrine-bundle 2.13: Enabling the controller resolver automapping feature has been deprecated. Symfony Mapped Route Parameters should be used as replacement.
Hide context Hide trace
[▼
  "exception" => 
Symfony\Component\ErrorHandler\Exception
\
SilencedErrorContext {#1665 ▶}
]
{▼
  
C:\wamp64\www\natheo\vendor
\doctrine\doctrine-bundle\
src\DependencyInjection\DoctrineExtension.php:533 {▼
    
Doctrine\Bundle\DoctrineBundle\DependencyInjection
\
DoctrineExtension->ormLoad(array $config, ContainerBuilder $container) …
    › if ($config['controller_resolver']['auto_mapping'] === true) {
    ›     trigger_deprecation('doctrine/doctrine-bundle', '2.13', 'Enabling the controller resolver automapping feature has been deprecated. Symfony Mapped Route Parameters should be used as replacement.');
    › }
  }
  
C:\wamp64\www\natheo\vendor
\doctrine\doctrine-bundle\
src\DependencyInjection\DoctrineExtension.php:121 {▼
    › 
    ›     $this->ormLoad($config['orm'], $container);
    › }
  }
}

Solution

  • Set auto_mapping to false.

    doctrine:
        orm:
            controller_resolver:
                auto_mapping: false