Recently I wrote question about PHP DOM manipulating:

So, I decided to use queryPath ( for PHP DOM Manipulation. I want to implement QueryPath as a service, that returns the object who can manipulate with DOM of the current action view. But I can not understand how to get the current view's content in callback function.

I did this in the following way:

$di->setShared('qp', function() use ($di)
                    $view = $di->getShared("view");
                    $dispatcher = $di->getShared("dispatcher");

                    return \QueryPath::with($view->getContent());

But it seems too complicated. Is there a better way to get contents of the current action view?