private function setGlobals()
    {
        /** @var Environment $twig */
        $twig = $this->app['twig'];
        /** @var \Bolt\Config $config */
        $config = $this->app['config'];
        /** @var \Bolt\Users $users */
        $users = $this->app['users'];
        $zone = null;
        /** @var RequestStack $requestStack */
        $requestStack = $this->app['request_stack'];
        if ($request = $requestStack->getCurrentRequest()) {
            $zone = Zone::get($request);
        }

        // User calls can cause exceptions that block the exception handler
        try {
            /** @deprecated Deprecated since 3.0, to be removed in 4.0. */
            $usersVal = $users->getUsers();
            $usersCur = $users->getCurrentUser();

            $sandbox = $this->app['twig.extension.sandbox'];
            $usersVal = array_map(function ($user) use ($sandbox) {
                return new ArrayAccessSecurityProxy($user, $sandbox, 'User');
            }, $usersVal);
            $usersCur = new ArrayAccessSecurityProxy($usersCur, $sandbox, 'User');
        } catch (\Exception $e) {
            $usersVal = null;
            $usersCur = null;
        }

        $twig->addGlobal('frontend', $zone === Zone::FRONTEND);
        $twig->addGlobal('backend', $zone === Zone::BACKEND);
        $twig->addGlobal('async', $zone === Zone::ASYNC);
        $twig->addGlobal('theme', $config->get('theme'));
        $twig->addGlobal('user', $usersCur);
        $twig->addGlobal('users', $usersVal);
    }