2

我们如何通过添加Backend.Behaviors.RelationController到其中一个控制器来扩展插件?我需要扩展用户插件belongsToMany并为其User模型添加关系。我还想扩展它的Users控制器来实现这个Backend.Behaviors.RelationController行为。我知道表单字段可以使用扩展extendFormFields,列表列可以使用扩展extendListColumns。但是如何通过添加或编辑RelationController行为来扩展插件呢?

4

1 回答 1

2

阅读Behavior 文档,特别是与扩展类以实现新行为有关的内容。

本质上,您将需要扩展用户控制器以实现RelationController行为并配置该行为。一个实现该功能的代码示例如下:

UsersController::extend(function($controller) {
    $controller->implement[] = ['Backend.Behaviors.RelationController'];
    $controller->relationConfig = '$/myvendor/myplugin/controllers/users/config_relation.yaml'
});
于 2016-12-27T10:30:01.940 回答