Phi*_*ord 5 php symfony fosuserbundle
// MySomethingController.php
// look no s
public function getSomethingAction($args)
{
...
}
Run Code Online (Sandbox Code Playgroud)
// routing.yml
my_something:
type: rest
resource: Blah\Bundle\BlahBundle\Controller\MySomethingController
Run Code Online (Sandbox Code Playgroud)
运行:
php app/console router:debug
Run Code Online (Sandbox Code Playgroud)
输出:
[router] Current routes
Name Method Pattern
get_something GET /somethings/{args}.{_format}
Run Code Online (Sandbox Code Playgroud)
为什么路线''somethings'(复数与's')而不是'某事'?
这是我在某处的设置吗?或者这是预期的吗?
深入研究代码后:
这里是:
private function generateUrlParts(array $resources, array $arguments)
{
$urlParts = array();
foreach ($resources as $i => $resource) {
// if we already added all parent routes paths to URL & we have
// prefix - add it
if (!empty($this->routePrefix) && $i === count($this->parents)) {
$urlParts[] = $this->routePrefix;
}
// if we have argument for current resource, then it's object.
// otherwise - it's collection
if (isset($arguments[$i])) {
if (null !== $resource) {
$urlParts[] =
strtolower(Pluralization::pluralize($resource))
.'/{'.$arguments[$i]->getName().'}';
} else {
$urlParts[] = '{'.$arguments[$i]->getName().'}';
}
} elseif (null !== $resource) {
$urlParts[] = strtolower($resource);
}
}
return $urlParts;
}
Run Code Online (Sandbox Code Playgroud)
我打开了一个问题:
希望这将成为可选的
| 归档时间: |
|
| 查看次数: |
2258 次 |
| 最近记录: |