RFC: New Prototype `Neos.Fusion:Switch`

I think this is an improvement for the following reasons:

The implicit use of the prototype Neos.Fusion:Matcher in the Case has a few downsides:

  • the php implementation is a bit hacky with the MATCH_NORESULT pattern
    • this seems a bit against how fusion objects are supposed to work as the Neos.Fusion:Matcher is not usable standalone.
    • not all fusion features like @process are working and cause odd (understandable) glitches
  • using the matcher as layer in between was probably only done to allow the use of this in the condition (at least there is a test for that)
    • using this is not that important in todays Fusion world with props and private.
    • note that our proposed @case will not have access to this, but that should be understandable from the scope in other languages as the condition is separate.
  • for its main use-case, as we perceive it, mostly the renderer option is used instead of type and rendererPath. That leads to additional boilerplate code.
  • the naming of the Neos.Fusion:Matcher has been there first but the introduction of the Neos.Fusion:Match conflicts now with it and leads to conFusion.
  • the default case must be implemented via condition = true, which is a bit verbose as well.
  • its basically impossible to use the case and matcher in afx due to its structure: Neos.Fusion:Case in afx or should we have a Neos.Fusion:If?
  • The Neos.Fusion:Renderer should in my opinion be split up into two more explicit prototypes (discussion). The Neos.Fusion:Matcher inheriting from it makes this a bit hard to completely get rid of the renderer, renderPath and type functionality in one object. So in my plan it would fit perfectly together to deprecate both and provide better dedicated replacements.

So in conclusion:

On long term we could replace the CaseImplementation and MatcherImplementation with one SwitchImplementation, which is easier to understand, has a more fitting naming and better usability due to less boilerplate code required by the fusion integrator.

2 Likes