I have a paragraph called Boxes which is a parent paragraph referencing to many paragraphs of type Box. I have written the preprocess function of paragraph Boxes which contains some logic that can't be done elsewhere. The result of that code is stocked in a variable called custom_color_weight.
I wanna access this variable in the box paragraph template but I can't move the code that yielded that variable's value outside the preprocess boxes function.
I was searching for a way to pass the variable from preprocess boxes to the preprocess box and hence to the template of the box paragraph Is there any way to do it?
Ps : I can't use getParentEntity in the preprocess Box function to get each time the parent Boxes entity and calculate the value of custom_color right there because that way I will be loading the parent paragarph entity multiple times as I have multiple nested paragraphs of type Box inside the paragraph Boxes.