neos / rector

Neos Rector Recipes for code migrations
6 stars 4 forks source link

Replace PrimaryContent usages automatically #78

Open bwaidelich opened 1 month ago

bwaidelich commented 1 month ago

Currently usages of Neos.Neos:PrimaryContent are not replaced automatically.

Instead a comment is added to the top of using files:

// TODO 9.0 migration: You need to refactor "Neos.Neos:PrimaryContent" to use "Neos.Neos:ContentCollection" instead.

// ...

main = Neos.Neos:PrimaryContent

Instead, we could consider replacing those usages directly.

Danger: With the current rectors it's not possible yet, to only replace the usages of the prototypes.. If we were to use the FusionReplacePrototypeNameRector to replace PrimaryContent, overrides such as

prototype(Neos.Neos:PrimaryContent) {
  someCustomCase {
    condition = ...
    renderer = 'this will be lost'
  }
}

would be replaced, too.

So, we would need to extend the FusionReplacePrototypeNameRector by some flag that allows us to exclude prototype definitions. Also we should extend other rectors like FusionPrototypeNameAddCommentRector such that the can target only prototype definitions/overrides.

Alternatively we should just keep Neos.Neos:PrimaryContent usages for now since the prototype still exists in 9.0 (even if deprecated)

Relates: