akeeba / fof

Rapid Application Development framework for Joomla!™ 3 and 4
0 stars 0 forks source link

Refactor XML form fields using Traits #615

Closed nikosdion closed 6 years ago

nikosdion commented 8 years ago

There's currently a lot of code overlap and duplication in XML form field classes. That stems from being strictly PHP 5.3 only. We had to extend from the JFormField classes so as not to reinvent Joomla's wheel but we also had to implement the Interfaces to our own fields. Moreover, fields which inherited from each other in Joomla couldn't use the same inheritance in FOF, therefore we had to duplicate code (think of all the text-related fields...).

The solution is to go PHP 5.4+ only and use Traits. Refactoring field classes with traits lets us inherit from the Joomla classes and implement our functionality with Traits.

The only downside is that Traits cannot inherit from each other. This will require some clever use of layered Traits, each one defining one more method we can then combine in a method of our object. It's tortoises, no, Traits all the way down...

nikosdion commented 6 years ago

We decided to get rid of XML forms in FOF 4.