[MAGNOLIA-7060] Override properties in YAML include Created: 08/Jun/17  Updated: 31/Jan/18  Resolved: 31/Jul/17

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 5.5.4
Fix Version/s: 5.5.6, 5.6

Type: New Feature Priority: Major
Reporter: Christopher Zimmermann Assignee: Aleksandr Pchelintcev
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MAGNOLIA-6664 Inheritance of registry definitions f... Closed
relation
is related to MAGNOLIA-7115 Parsing of yaml fragment attempts to ... Closed
Template:
Acceptance criteria:
Empty
Release notes required:
Yes
Epic Link: LD: Fundamental features
Sprint: Basel 103, Basel 104, Basel 105, Basel 106, Basel 107
Story Points: 3

 Description   

Enhance "!include" for YAML.

  • Add ability to override properties and nodes by supplying them under the !include statement. (Similar to how one can supply properties and node with "extends" in JCR)
  • Supports override keyword to stop the extending.
  • Introduce a new no-space syntax to be valid YAML: !include:/light-yaml-sample/samples/sampleTab.yaml
  • Deprecate (but still support) the existing "space-syntax" and print warning (if possible) when detected (However, override is not supported on the space-syntax): !include light-yaml-sample/samples/sampleTab.yaml

Note: this is a part of the "Inheritance of definitions from registry" initiative (former "YAML extends").
https://wiki.magnolia-cms.com/display/PMTEAM/YAML+extends+LDV
After discussion it was decided not to introduce the term "extends" for YAML to prevent confusion between how the feature functions in JCR.



 Comments   
Comment by Christopher Zimmermann [ 08/Jun/17 ]

Feature should work as proposed here as "!extend", (except it is available on the existing "!include" keyword instead):
https://www.magnolia-cms.com/blogs/aleksandr-pchelintcev/detail~@yaml-extensions-for-lighter-development--to-jcr-and-beyond~.html

Most relevant:

form:
  tabs:
    # We extend a sample tab here and add a fourth field definition.
    - !extend:/light-yaml-sample/samples/sampleTab.yaml
      name: extendedTab
      fields:
        - name: qux
          class: i.m.ui.form.field.definition.LinkFieldDefinition
        # We also change the type of the field foo from simple text field to a rich-text field
        - name: foo
          class: i.m.ui.form.field.definition.RichTextFieldDefinition
# Actions are reused from the sampple file as
actions: !extend:/light-yaml-sample/samples/common-actions.yaml

AND:

# We specify the type of a definition we are going to extend (in this case it is 'dialog' which automatically maps to the DialogDefinitionRegistry) and the target definition reference in the registry,
# for the case of dialogs it consists of a module name + definition name

!extend-def:dialog:light-yaml-sample:dialogA
form:
  tabs:
    - name: extendedTab    
      # Despite the fact that we extend dialogA definition, the 'extendedTab' will contain only one field definition since we annotate 'fields' list with !override tag
      fields: !override
        - name: quux
          class: i.m.ui.form.field.definition.TextFieldDefinition
Generated at Mon Feb 12 04:20:21 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.