RFC: Enable inheritance for NodeType properties

Mixins are great!
But the names of mixin-properties can’t change and they can collide soon if you work with a lot of mixins and / or if you work a long time at the same project.

Proposal: Inheritance syntax for properties in yaml.

Example:

Vendor.Project:BasicPropertiesMixin:
  abstract: true
  properties:
    singleline-inspector:
      # basic property configuration
    text-inplace:
      # basic property configuration

Vendor.Project:Person:
  superTypes:
    'Vendor.Project:BasicProperties': true
  properties:
    'firstname < singleline-inspector': []
    'lastnamename < singleline-inspector': []
    'description < text-inplace':
      # override the basic property configuration
      ui:
        aloha:
          placeholder: 'About this Person'

To get this functionality we need at least the following changes:


Would be great to get this or a better solution in to the core.

2 Likes

In the currently proposed solution, the finally not needed properties singleline-inspector and text-inplace have to be removed with a postprocessor in this example.

But I would not clean up these properties automatically because the example could also look like the following:

Vendor.Project:PersonPropertiesMixin:
  abstract: true
  properties:
    firstname:
      # ...
      ui:
        label: 'First name'
    description:
      # ...
      ui:
        aloha:
          placeholder: 'About this Person'

Vendor.Project:Person:
  superTypes:
    'Vendor.Project:PersonPropertiesMixin': true
  properties:
    # add missing properties, based on already defined ones:
    'middlename < firstname':
      ui:
        label: 'Middle name'
    'lastname < firstname':
      ui:
        label: 'Last name'

Hey Stefan,

thanks for your ideas and participation to the project!

I personally think this change would be quite dangerous and hard-to-grasp for people, which is why I would not like to support this. Did you know you can use YAML Anchors to share common configuration parts, as explained in https://gist.github.com/bowsersenior/979804 ?

The drawback is that this would only work in the same file; but that’s probably OK!

All the best,
Sebastian

Hi Sebastian,

That’s the main problem, to deliver project-wide property defaults this won’t work.

True. It’s an additional dimension to think about while creating NodeTypes.
But if it’s used right, it allows slimmer and non-breaking NodeType-Properties.

Maybe it’s a way to refactor the NodeTypeManager and YamlSource with Interfaces, so that they can get replaced by design?

1 Like

Hey Stefan,

I’d be fine with the direction of adding the necessary hooks / interfaces for NodeTypeManager or Configuration Framework in order to hook into this in an extra package :slight_smile:

If you need help figuring out the exact places, let me know :heart:

All the best,
Sebastian

2 Likes

There’s already the NodeTypePostprocessorInterface that allows you to enrich all kinds of node type configurations. Does that work for you?

No this did not worked out, that was my first try: https://gist.github.com/sbruggmann/53d73f02c2046dbcefcdb4529318c1d5
This way there was a problem with i18n fields of inherited properties and it was not possible to inject changes to basic mixins at a later state.

so… here is my result:
Flow PR: https://github.com/neos/flow-development-collection/pull/750
(Neos PR: https://github.com/neos/neos-development-collection/pull/1292)

And an implementation example which finally allows the property inheritance:

Let me know what you all think about this :slight_smile: