blipson89 / Synthesis

Synthesis is a universal object mapper for Sitecore
MIT License
75 stars 25 forks source link

Question with multiple interfaces in Helix #51

Closed ajgreenman closed 7 years ago

ajgreenman commented 7 years ago

Hey Kam,

I've run into an issue in my current Sitecore solution (Sitecore 8.2 and Synthesis 8.2.5). I have a template in the Project layer whose base templates are two different interfaces (one from Feature, one from Foundation). Now, when I go to write code in a Feature controller whose datasource item uses this template, I can only cast it to one of the two interfaces (because the actual template model is located in the Project layer).

Is there a way to get a model for this item without referencing the Project layer model? It would be nice to be able to get both the Feature and Foundation models out of this single datasource item.

Thanks!

ajgreenman commented 7 years ago

I just want to add on to this that I did think about making the Feature interface inherit the Foundation interface. While this would work, it wouldn't work for two interfaces from different Features (as that would break Helix). So the same question applies in that situation. Thanks!

kamsar commented 7 years ago

It seems like the issue is less one of Synthesis, and more a philosophical question of how to interpret Helix guidelines. All Synthesis does in this case is to codify the dependencies of the templates in Sitecore into actual project reference dependencies in the code.

For this particular scenario, it seems like doing a null cast to the other type might be a decent stopgap, if you cannot have the inheritance hierarchy be linear.