Hi all,
I'm trying to access a service I have set in my DI, from my Volt template, but I keep getting the "Undefined variable" error. I am able to access other services from the template, just not this particular one. Below is part of my bootstrap file:
<?PHP
    # Load config
    $Config = require '../app/config/config.php';
    $DI->setShared('config',$Config);
    # Set up the View component
    $DI->set('view',function() use($Config){
        $View = new \Phalcon\Mvc\View();
        $View->setViewsDir($Config->dir->views_dir);
        $View->registerEngines(['.phtml'=> function($View,$DI) use ($Config){
                                            $Volt = new \Phalcon\Mvc\View\Engine\Volt($View,$DI);
                                            return $Volt;
                                        }
                            ]);
        return $View;
    });
    # Check authorization
    $Auth = new Auth($DI);
    if($Auth->authorize()){
        $DI->setShared('user',$Auth->getUser());
    }
    else{
        $DI->get('view')->render('system','notallowed');
        exit();
    }
From my template, I am able to access Config like:
{{ Config.dir.app_dir_web }}
just not "User".
UPDATE: Reviewing my controller code I see I'm manually setting the Config variable, so it's not automagically accessible. In the documentation section about injecting services into Volt, it says "If a service container (DI) is available for Volt". What does that mean? Do I need to do anything in particular to make the my DI available to Volt?