gpt4 book ai didi

php - 将路线从旧格式迁移到新格式,这方面的文档在哪里?丢失的?

转载 作者:行者123 更新时间:2023-12-01 20:17:46 27 4
gpt4 key购买 nike

也许您可能会从我最近的上一篇文章中注意到,我正在开发 SF2.0.x 应用程序到新的 SF2.7。现在我收到了很多通知,它们不会影响应用程序功能,但它会影响应用程序功能,我想防止这种情况发生。我已阅读Routing SF Book 章节,The Routing Component还有@ Route and @Method注释但找不到任何有助于解决问题的信息。所以我需要这里人们的帮助。现在,路由如下所示(XML 格式):

<route id="PDOneBundle_repproject_process" path="/project/{page}/{action}">
<default key="_controller">PDOneBundle:ProjectDetail:process</default>
<requirement key="page">\w+</requirement>
<requirement key="action">add|update|delete</requirement>
<requirement key="_format">html</requirement>
<requirement key="_method">POST|GET</requirement>
</route>

下面的消息是我收到的通知:

DEPRECATED - The "_method" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the setMethods() method instead or the "methods" option in the route definition.

现在定义路线的正确方法是什么?

最佳答案

您应该阅读以下内容:

https://github.com/symfony/symfony/blob/master/UPGRADE-3.0.md

您搜索的部分:

Routing

Some route settings have been renamed:
The pattern setting for a route has been deprecated in favor of path
The _scheme and _method requirements have been moved to the schemes and methods settings

Before:

article_edit:
pattern: /article/{id}
requirements: { '_method': 'POST|PUT', '_scheme': 'https', 'id': '\d+' }

<route id="article_edit" pattern="/article/{id}">
<requirement key="_method">POST|PUT</requirement>
<requirement key="_scheme">https</requirement>
<requirement key="id">\d+</requirement>
</route>

$route = new Route();
$route->setPattern('/article/{id}');
$route->setRequirement('_method', 'POST|PUT');
$route->setRequirement('_scheme', 'https');

After:

article_edit:
path: /article/{id}
methods: [POST, PUT]
schemes: https
requirements: { 'id': '\d+' }

<route id="article_edit" path="/article/{id}" methods="POST PUT" schemes="https">
<requirement key="id">\d+</requirement>
</route>

$route = new Route();
$route->setPath('/article/{id}');
$route->setMethods(array('POST', 'PUT'));
$route->setSchemes('https');

关于php - 将路线从旧格式迁移到新格式,这方面的文档在哪里?丢失的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29632182/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com