I would like to act with a differential operator $D_x = x \partial_x^2+3\partial_x$ on a function $g(x)$ to compute something like $$ ((D_x)^2 +D_x) g(x) $$ Clearly, in this simple example, this does the trick
dop[t_] := t D[#, {t, 2}] + 3 D[#, t] &
dop[x][dop[x][g[x]]] + dop[x][g[x]]
However, in my case I have more derivatives and I would like to do things differently. I would like to more generally define a function $f(x) = x^2+x$ and then consider $$ f(D_x)g(x) = ((D_x)^2 +D_x) g(x) $$
How can I define this function $f(D_x)$ in Mathematica?