Answer the question
In order to leave comments, you need to log in
How to avoid spaghetti code in result_modifier?
Working with result_modifier.php forces you to write spaghetti code. It becomes impossible to maintain this footcloth. How to refactor?
It seems like a normal solution might be to use a component factory (factory method pattern). Create a factory for each component (bitrix:news.list, bitrix:news.detail ...). In the result_modifier.php of the component template, get the required class from the factory with static methods for this particular result_modifier.php.
Is there any generally accepted approach?
Answer the question
In order to leave comments, you need to log in
There is no need to do something in the form of a module for a separate project.
I do this (and often see a similar approach):
In /local/php_interface/lib I place classes that implement some functionality of a particular project, and connect it using composer autoload:
Here you can place classes that implement the module and just ordinary helpers - I don’t see anything what's wrong with a procedural approach is if all the ideas are implemented as simple, short and minimally functional pure static methods.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question