I have heard that at one time the Blessed One was staying in Savatthi at Jeta's Grove, Anathapindika's park. There he addressed the monks, saying, "Monks!"
"Yes, lord," the monks responded to him.
The Blessed One said, "I will teach & analyze for you the origination and subsiding of the four establishings of mindfulness. Listen & pay close attention. I will speak."
"As you say, lord," the monks responded to him.
The Blessed One said, "And what, monks, is the origination of the body?  From the origination of nutriment is the origination of the body. From the cessation of nutriment is the subsiding of the body.
"From the origination of contact is the origination of feeling. From the cessation of contact is the subsiding of feeling.
"From the origination of name-&-form is the origination of the mind. From the cessation of name-&-form is the cessation of the mind.
"From the origination of attention is the origination of mental qualities.  From the cessation of attention is the subsiding of mental qualities."
Mental qualities = dhammas. SN 46.51 discusses the ways in which inappropriate attention feeds such unskillful mental qualities as the hindrances, whereas appropriate attention feeds such skillful mental qualities as the factors for awakening.
Dhammas can also mean "phenomena," "events," or "actions." It is apparently in connection with these three meanings that AN 10.58 lists three factors underlying the appearance of dhammas:
"All phenomena are rooted in desire.
"All phenomena come into play through attention.
"All phenomena have contact as their origination."