This commit is contained in:
jiangtao
2017-09-28 14:14:22 +08:00
parent a193b06bd8
commit aebcafe04c

View File

@ -73,16 +73,16 @@
]
```
您可能已经注意到控制器ID`user`以复数形式出现在`users`末端。这是因为 [[yii\rest\UrlRule]] 能够为他们使用的末端全自动复数化控制器ID
您可以通过设置 [[yii\rest\UrlRule::pluralize]] 为false 来禁用此行为,如果您想
使用一些特殊的名字您可以通过置 [[yii\rest\UrlRule::controller]] 属性
您可能已经注意到控制器ID `user` 以复数形式出现在 `users` 末端。
这是因为 [[yii\rest\UrlRule]] 能够为他们使用的末端全自动复数化控制器 ID。
您可以通过置 [[yii\rest\UrlRule::pluralize]] 为 false 来禁用此行为
> Info: The pluralization of controller IDs is done by [[yii\helpers\Inflector::pluralize()]]. The method respects
special pluralization rules. For example, the word `box` will be pluralized as `boxes` instead of `boxs`.
> 信息:控制器的 ID 复数化由 [[yii\helpers\Inflector::pluralize()]] 完成。该方法遵循
特定的规则. 举个例子, 单词 `box` 会被复数化为 `boxes` 而不是 `boxs`
In case when the automatic pluralization does not meet your requirement, you may also configure the
[[yii\rest\UrlRule::controller]] property to explicitly specify how to map a name used in endpoint URLs to
a controller ID. For example, the following code maps the name `u` to the controller ID `user`.
如果自动复数化不能满足你的需求,你也可以配置
[[yii\rest\UrlRule::controller]] 属性来明确指定如何将端点URL中使用的名称映射到
控制器ID。例如以下代码将名称 `u` 映射到控制器ID `user`
```php
[
@ -91,10 +91,10 @@ a controller ID. For example, the following code maps the name `u` to the contro
]
```
## Extra configuration for contained rules
## 包含规则的额外配置
It could be useful to specify extra configuration that is applied to each rule contained within [[yii\rest\UrlRule]].
A good example would be specifying defaults for `expand` parameter:
在 [[yii\rest\UrlRule]] 中所包含的每个规则中,指定额外的配置可能很有用。
一个很好的例子就是指定 `expand` 参数的默认值:
```php
[