Symfony 7.1 - Doctrine 2.13 自动映射功能弃用

问题描述 投票:0回答:1

我正在 Symfony 7.1 中开发一个项目,自上次更新以来,我遇到了以下弃用的小问题:

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

深入研究 Symfony 文档,我发现一篇文章讨论了它并提供了纠正弃用的解决方案:https://symfony.com/blog/new-in-symfony-7-1-mapped-route -参数

在这个帮助下,我检查了所有控制器以进行必要的更正,但弃用仍然存在......

我重读了代码 3 次,我无法理解为什么弃用仍然存在。

我所做的一些更正示例:

 #[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

我是不是误会了什么?

有没有技巧可以知道触发折旧的确切位置?

不幸的是,我收到的消息太模糊,没有指出导致问题的地方。

    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);
    › }
  }
}

提前感谢您的帮助

我为我糟糕的英语道歉

symfony doctrine-orm doctrine symfony7
1个回答
0
投票

将 auto_mapping 设置为 false。

doctrine:
    orm:
        controller_resolver:
            auto_mapping: false
© www.soinside.com 2019 - 2024. All rights reserved.