mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-06 16:07:18 +08:00
'commit'
This commit is contained in:
@ -73,16 +73,16 @@
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
您可能已经注意到控制器ID`user`以复数形式出现在`users`末端。这是因为 [[yii\rest\UrlRule]] 能够为他们使用的末端全自动复数化控制器ID。
|
您可能已经注意到控制器ID `user` 以复数形式出现在 `users` 末端。
|
||||||
您可以通过设置 [[yii\rest\UrlRule::pluralize]] 为false 来禁用此行为,如果您想
|
这是因为 [[yii\rest\UrlRule]] 能够为他们使用的末端全自动复数化控制器 ID。
|
||||||
使用一些特殊的名字您可以通过配置 [[yii\rest\UrlRule::controller]] 属性。
|
您可以通过设置 [[yii\rest\UrlRule::pluralize]] 为 false 来禁用此行为。
|
||||||
|
|
||||||
> Info: The pluralization of controller IDs is done by [[yii\helpers\Inflector::pluralize()]]. The method respects
|
> 信息:控制器的 ID 复数化由 [[yii\helpers\Inflector::pluralize()]] 完成。该方法遵循
|
||||||
special pluralization rules. For example, the word `box` will be pluralized as `boxes` instead of `boxs`.
|
特定的规则. 举个例子, 单词 `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
|
[[yii\rest\UrlRule::controller]] 属性来明确指定如何将端点URL中使用的名称映射到
|
||||||
a controller ID. For example, the following code maps the name `u` to the controller ID `user`.
|
控制器ID。例如,以下代码将名称 `u` 映射到控制器ID `user`。
|
||||||
|
|
||||||
```php
|
```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]].
|
在 [[yii\rest\UrlRule]] 中所包含的每个规则中,指定额外的配置可能很有用。
|
||||||
A good example would be specifying defaults for `expand` parameter:
|
一个很好的例子就是指定 `expand` 参数的默认值:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user