dispatcher get new instance instead of shared


I'm trying to get a new instance of view, which is declared as shared in bootstrap. I tried with $this->di->get("view") but is returning the shared one. There is any way to get a new instance of view?

So far I only see 2 options, but I don't quite like any of them:

  • set the current view as not shared in bootstrap, but this will break existing functionality
  • set a new view that is not shared


The reason question is why you need multiple instances of the view class instantiated?

Without understanding what your end goal is it's hard to suggest the best resolution for you.

Have you considered just directly referencing the class Phalcon\Mvc\View(); ?

edited Jul '15

I need it for widgets. If I use Phalcon\Mvc\View() nothing works. If I use the same instance, is also changing the main view entirely. In the mean time I just created a new viewWidget until I find a better solution.