Weird behaviour when picking view

I was using the $this->view->pick method in some action inside my controller and everything was working as expected. The main layout was working properly setting in the initialize method of my controller.

    public function initialize()

But then I created my own menu component which renders an specific view like this:

    public function getSideMenu()
        /** SOME CODE **/

        return $this->view->getRender('shared', 'side-menu', ['menu' => $menu], function ($view){

As you can see I changed the render level inside the anonymous function, I suppose that shouldn't affect my existing controllers but it does. Now the pick method skips the main.volt inside my views/layouts folder. Hierachical rendering works fine so most of my controllers aren't affected but the one using the pick view doesn't work fine.

Explicitly setting the render level isn't working:

    public function estatusEvaluatorioAction()
            /** SOME OTHER CODE **/
        $this->view->evaluados = $evaluados;

The only workarounds I've found are not using $this->view->getRender() method in the component or simply not picking the view (using the hierarchical rendering).

Do you know if this is some kind of bug or am I missing something?



what happens if you comment


@le51 it works exactly as if the line wasn't commented. Still getting same werid behaviour.