我们如何通过将 Backend.Behaviors.RelationController
添加到其 Controller 之一来扩展插件?我需要延长 User Plugin并将 belongsToMany
关系添加到其 User
模型。我还想扩展其 Users
Controller 来实现 Backend.Behaviors.RelationController
行为。我知道可以使用 extendFormFields
扩展表单字段,并且可以使用 extendListColumns
扩展列表列。但是通过添加或编辑 RelationController 来扩展插件怎么样?行为?
最佳答案
阅读Behavior documentation ,特别是因为它涉及扩展类以实现新行为。
本质上,您需要扩展 Users Controller 以实现 RelationController
行为并配置该行为。完成此操作的代码示例如下:
UsersController::extend(function($controller) {
$controller->implement[] = ['Backend.Behaviors.RelationController'];
$controller->relationConfig = '$/myvendor/myplugin/controllers/users/config_relation.yaml'
});
关于php - OctoberCMS:如何通过添加或编辑RelationController来扩展 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41072522/