views:

156

answers:

1

In my ACL fixtures I have resources and actions, most of the resources share common actions like CRUD, is there a way in Doctrine (yaml) to extend another element?

Here is a blurb from my current 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

How could I extend R1 with a new resource, called 'News article' for example, that would inherit A1 to A4 + include it's own actions?

+2  A: 

"Anchors and Aliases" + Merge is the answer:

http://yaml.github.com/yaml-spec/#id2768357

(Use http://instantyaml.appspot.com/ to see how the canonical YAML looks like)

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
Excellent, this has to be one of the most helpful answers I've received!
Andrei Serdeliuc