在我的ACL工具中,我有资源和操作,大多数资源都有共同的操作,比如CRUD,Doctrine(yaml)中有没有办法扩展另一个元素?
这是我当前名字中的一个模糊:
Resource:
R1:
title: Article
system_name: ARTICLE
Actions:
A1:
title: Create
system_name: CREATE
A2:
title: Read
system_name: READ
A3:
title: Update
system_name: UPDATE
A4:
title: Delete
system_name: DELETE
我如何使用新资源扩展R1,例如“新闻文章”,它会将A1继承到A4 +包括它自己的行为?
答案 0 :(得分:2)
“Anchors and Aliases”+ Merge就是答案:
http://yaml.github.com/yaml-spec/#id2768357
(使用http://instantyaml.appspot.com/查看规范YAML的外观)
Resource:
R1:
title: Article
system_name: ARTICLE
Actions: &id1
A1:
title: Create
system_name: CREATE
A2:
title: Read
system_name: READ
R2:
system_name: New ARTICLE
Actions:
<<: *id1
A5:
title: Drop
system_name: DROP