I have a content type called basic_page. This content type has a field called field_elements which is an entity reference field. The display settings for this field is set to 'Render Entity' - in other words, when a basic_page node is being rendered, it will also render the referenced entity. All good - no problem.
My question is, I would like to pass run-time information (based on basic_page node) to the referenced entity that should be used in mytheme_preprocess_node when the referenced entity is being 'pre-processed`.
The problem is, by the time hook_preprocess_node is called for the referenced entity - I have no information of the basic_page node that 'contains' the referenced entity.
I was hoping that in hook_preprocess_field I could check if it is field_element and then set some value in the &$variables param I am getting in hook_preprocess_field that will persist to exist up to the point where hook_preprocess_node is called?