As perhaps you may notice from my previous recently post I'm working on SF2.0.x app to new SF2.7. Right now I'm having a lot of NOTICE
and they don't affect app functionality but it will do and I want to prevent this. I have read Routing chapter at SF Book, The Routing Component and also @ Route and @Method annotations but can't find any helpful to fix the issue. So I need some help from people here. Right now, the routes, looks like the one below (in XML format):
<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>
And the message below is the NOTICE
I am getting:
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.
What is the right way to define the routes now?
You should read this:
https://github.com/symfony/symfony/blob/master/UPGRADE-3.0.md
And the part you searched:
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');