Kunstmaan / KunstmaanBundlesCMS

An advanced yet user-friendly content management system, based on the full stack Symfony framework combined with a whole host of community bundles. It provides a full featured, multi-language CMS system with an innovative page and form assembling process, versioning, workflow, translation and media managers and much more.
https://kunstmaancms.be
MIT License
399 stars 188 forks source link

Controller classes have been changed to final #3257

Open henrypenny opened 1 year ago

henrypenny commented 1 year ago

I'm trying to update an older Kunstmaan CMS site to Symfony 5. There are a lot of controllers in the project that extend the Kunstmaan Controller classes. I'm finding that many of them are now final This is making my upgrade process incredibly frustrating. What is the benefit of these classes being final? This is a big BC break for me. I'm having to copy and paste code out of the kunstmaan classes into user land controllers.

e.g.: final class SettingsController extends AbstractController

acrobat commented 1 year ago

Hi @henrypenny, sorry for the late answer! Regarding the final classes, this is a decision made to ease the maintainability of the code. In the past all classes where open to extension or had public properties/methods anyone could use and this made it hard to do required refactorings to improve our code base or add compatibility for newer symfony versions without breaking backwards compatibility.

That's why we decided to mark certain classes as final to allows us to make changes easier in the future. Those controllers have been marked with @final in the 5.x versions, thus triggering a symfony deprecation when you extend from these classes. So no BC break in theory. I ofcourse understand this might make some implementations difficult and ideally the controller logic is moved to a service, so that the controller just passed the request to a service and it returns a response. This way users of the cms can implement their own logic via a custom service.

Can you share some use cases where you have issues with now? Let's review those cases and find a solution that works for everbody!